顯示具有 Label 標籤的文章。 顯示所有文章
顯示具有 Label 標籤的文章。 顯示所有文章

2014年7月13日 星期日

[RESOLVED] Checkbox


I have a single checkbox...however I want to store the value of the checkbox into the database instead of having it show on the page....


what would i change cbpb2.text to?


If cbpb2.Checked = True Then
cbpb2.Text = "Y"
Else
cbpb2.Text = "N"
End If



 



By value do you mean the state or the label of the CheckBox? 



state



You can use a bit field and then you write 1 to it if the CheckBox is checked, otherwise 0/null. So when you check the CheckBox and it's "checked" Update this column to 1 otherwise 0.


[RESOLVED] Modal is closing used Update Panel.


I have a update panel which including 3 dropdownlist. and those dropdown items can change depend on first dropdown. and also I have modal popup independent these dropdownlists.

but when I click the button and open modal the page does postback and modal was closing quickly how can I get rid of this issues. and below this my code.


       







xxx


























xxxx





TL




xxx




















 





T-Law


but when I click the button and open modal the page does postback and modal was closing quickly how can I get rid of this issues.


You can stop the postback from button by adding return false like given below


  <%--Prevent the page postback using return false--%>



I am grateful to you A2H Master :)



Glad to be of help :)


[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] Run method after page has loaded


Hi. I have a method PingServer() which pings a server and then updates a label with Offline or Online. The method runs on page load. However, if the server is offline, the ping takes some time to complete, and the page will simply be blank until it finishes.


So I'm wondering how I can load the page and have the label say something like "Checking server status.." until the ping is complete?


Thanks!



Did you try doing a response.flush before your ping?



This could be something best done client-side using a web service. This way you can perform an ajax call that, when complete sets the label or indicates a failure message. That way the page can load up and go and not be hung up waiting for an external server
ping.


[RESOLVED] Checkbox


I have a single checkbox...however I want to store the value of the checkbox into the database instead of having it show on the page....


what would i change cbpb2.text to?


If cbpb2.Checked = True Then
cbpb2.Text = "Y"
Else
cbpb2.Text = "N"
End If



 



By value do you mean the state or the label of the CheckBox? 



state



You can use a bit field and then you write 1 to it if the CheckBox is checked, otherwise 0/null. So when you check the CheckBox and it's "checked" Update this column to 1 otherwise 0.


[RESOLVED] Modal is closing used Update Panel.


I have a update panel which including 3 dropdownlist. and those dropdown items can change depend on first dropdown. and also I have modal popup independent these dropdownlists.

but when I click the button and open modal the page does postback and modal was closing quickly how can I get rid of this issues. and below this my code.


       







xxx


























xxxx





TL




xxx




















 





T-Law


but when I click the button and open modal the page does postback and modal was closing quickly how can I get rid of this issues.


You can stop the postback from button by adding return false like given below


  <%--Prevent the page postback using return false--%>



I am grateful to you A2H Master :)



Glad to be of help :)


[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] Run method after page has loaded


Hi. I have a method PingServer() which pings a server and then updates a label with Offline or Online. The method runs on page load. However, if the server is offline, the ping takes some time to complete, and the page will simply be blank until it finishes.


So I'm wondering how I can load the page and have the label say something like "Checking server status.." until the ping is complete?


Thanks!



Did you try doing a response.flush before your ping?



This could be something best done client-side using a web service. This way you can perform an ajax call that, when complete sets the label or indicates a failure message. That way the page can load up and go and not be hung up waiting for an external server
ping.


[RESOLVED] Checkbox


I have a single checkbox...however I want to store the value of the checkbox into the database instead of having it show on the page....


what would i change cbpb2.text to?


If cbpb2.Checked = True Then
cbpb2.Text = "Y"
Else
cbpb2.Text = "N"
End If



 



By value do you mean the state or the label of the CheckBox? 



state



You can use a bit field and then you write 1 to it if the CheckBox is checked, otherwise 0/null. So when you check the CheckBox and it's "checked" Update this column to 1 otherwise 0.


[RESOLVED] Modal is closing used Update Panel.


I have a update panel which including 3 dropdownlist. and those dropdown items can change depend on first dropdown. and also I have modal popup independent these dropdownlists.

but when I click the button and open modal the page does postback and modal was closing quickly how can I get rid of this issues. and below this my code.


       







xxx


























xxxx





TL




xxx




















 





T-Law


but when I click the button and open modal the page does postback and modal was closing quickly how can I get rid of this issues.


You can stop the postback from button by adding return false like given below


  <%--Prevent the page postback using return false--%>



I am grateful to you A2H Master :)



Glad to be of help :)


[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] Run method after page has loaded


Hi. I have a method PingServer() which pings a server and then updates a label with Offline or Online. The method runs on page load. However, if the server is offline, the ping takes some time to complete, and the page will simply be blank until it finishes.


So I'm wondering how I can load the page and have the label say something like "Checking server status.." until the ping is complete?


Thanks!



Did you try doing a response.flush before your ping?



This could be something best done client-side using a web service. This way you can perform an ajax call that, when complete sets the label or indicates a failure message. That way the page can load up and go and not be hung up waiting for an external server
ping.


[RESOLVED] Checkbox


I have a single checkbox...however I want to store the value of the checkbox into the database instead of having it show on the page....


what would i change cbpb2.text to?


If cbpb2.Checked = True Then
cbpb2.Text = "Y"
Else
cbpb2.Text = "N"
End If



 



By value do you mean the state or the label of the CheckBox? 



state



You can use a bit field and then you write 1 to it if the CheckBox is checked, otherwise 0/null. So when you check the CheckBox and it's "checked" Update this column to 1 otherwise 0.


[RESOLVED] Modal is closing used Update Panel.


I have a update panel which including 3 dropdownlist. and those dropdown items can change depend on first dropdown. and also I have modal popup independent these dropdownlists.

but when I click the button and open modal the page does postback and modal was closing quickly how can I get rid of this issues. and below this my code.


       







xxx


























xxxx





TL




xxx




















 





T-Law


but when I click the button and open modal the page does postback and modal was closing quickly how can I get rid of this issues.


You can stop the postback from button by adding return false like given below


  <%--Prevent the page postback using return false--%>



I am grateful to you A2H Master :)



Glad to be of help :)


[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] Run method after page has loaded


Hi. I have a method PingServer() which pings a server and then updates a label with Offline or Online. The method runs on page load. However, if the server is offline, the ping takes some time to complete, and the page will simply be blank until it finishes.


So I'm wondering how I can load the page and have the label say something like "Checking server status.." until the ping is complete?


Thanks!



Did you try doing a response.flush before your ping?



This could be something best done client-side using a web service. This way you can perform an ajax call that, when complete sets the label or indicates a failure message. That way the page can load up and go and not be hung up waiting for an external server
ping.


[RESOLVED] Checkbox


I have a single checkbox...however I want to store the value of the checkbox into the database instead of having it show on the page....


what would i change cbpb2.text to?


If cbpb2.Checked = True Then
cbpb2.Text = "Y"
Else
cbpb2.Text = "N"
End If



 



By value do you mean the state or the label of the CheckBox? 



state



You can use a bit field and then you write 1 to it if the CheckBox is checked, otherwise 0/null. So when you check the CheckBox and it's "checked" Update this column to 1 otherwise 0.


[RESOLVED] Modal is closing used Update Panel.


I have a update panel which including 3 dropdownlist. and those dropdown items can change depend on first dropdown. and also I have modal popup independent these dropdownlists.

but when I click the button and open modal the page does postback and modal was closing quickly how can I get rid of this issues. and below this my code.


       







xxx


























xxxx





TL




xxx




















 





T-Law


but when I click the button and open modal the page does postback and modal was closing quickly how can I get rid of this issues.


You can stop the postback from button by adding return false like given below


  <%--Prevent the page postback using return false--%>



I am grateful to you A2H Master :)



Glad to be of help :)


[RESOLVED] How do I get the Windows user so I can display it?


I'm starting a new Web Forms app that's meant to run only as an Intranet application. We're a Microsoft shop, and all users log into our company's Active Directory. I'd like to be able to display the user's name in a small label (scan) on the page via the
Site.Master file. I've searched online and it looked as though I could use this line:


string strName = Request.ServerVariables["AUTH_USER"];

However, when I turned Trace on for the Default.aspx page, I discovered that the server variable AUTH_USER was empty, so that doesn't look like it's going to work for me. So how can I get it done?


I'm using .NET 4.5 in VS 2012.



Try this: string strName = this.Context.Request.LogonUserIdentity.Name



That gives me:


NT AUTHORITY\IUSR



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.



I use this: 


 strName = HttpContext.Current.User.Identity.Name




Hi,


Always use User.Identity.Name that returns the current user regardless of which authentication method is used. If blank, check User.IsAuthenticated to confirm that a proper authentication method is currently not in place.


More likely you perhaps enabled Windows authentication but forgot to disable anonymous authentication in which case anonymous authentication is still used...





markfitzme



This will most likely only work if you deny anonymous users. If anonymous users are allowed it's just running within the security context of the application pool's user account, which is IUSR.





Please correct me if I'm wrong, but if I deny anonymous users, won't that require the user to log in? This is meant to be an Intranet application and so anyone sitting at their Windows PC in our network should be able to get in without having to log in.
However, if I'm wrong please let me know.



Exactly, if they are an intranet user you would not need anonymous logon.  The only time you would need that is if you were using webforms security for an internet application.



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application




Yes but if you don't need anonymous authentication it might be easier to just disable this rather than to deny access to anonymous users. Anyway please do check User.IsAuthenticated. If false your current config is not correct and either you'll have to fix
this or you could just disable anonymous authentication toa make sure it just can't be used.





markfitzme



It's been a while since I deployed an intranet app, but if you're using windows authentication instead of forms, then the user has already logged into the domain and that should be the account the app will use for login credentials. 


Here is a reference I found: http://weblogs.asp.net/scottgu/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application






This was helpful. Here's the steps I took:



  1. Went into IIS on my Windows 7 machine, and the IIS | Authentication for Windows Authentication from Disabled to Enabled (which is what I think Scott Gu would have meant for Windows 7).
  2. Added these lines to my Web.Config:






Next I ran the app using F5. It did come up, and it did show me as the authenticated user, as well as the domain I'm on. But it didn't do that without complaints. It raised this error:



[RESOLVED] Run method after page has loaded


Hi. I have a method PingServer() which pings a server and then updates a label with Offline or Online. The method runs on page load. However, if the server is offline, the ping takes some time to complete, and the page will simply be blank until it finishes.


So I'm wondering how I can load the page and have the label say something like "Checking server status.." until the ping is complete?


Thanks!



Did you try doing a response.flush before your ping?



This could be something best done client-side using a web service. This way you can perform an ajax call that, when complete sets the label or indicates a failure message. That way the page can load up and go and not be hung up waiting for an external server
ping.