Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

i would like to know the coding inside the login button that the ASP.Net generates automatically when i start the new Website. the button is in the Login.aspx form and insite the asp:Login tag.
it says like this :

<asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup"/>

I curious with :

1. CommandName = "Login" what is that ?
2. Where ASP.Net put the code to execute it ? since i want to see how ASP.Net do login for me.

thanx a lot.
Posted
Updated 8-Dec-10 17:52pm
v3

1 solution

Hi,

this is used in the buttons event handler that can be set via attribute OnCommand. Then in the event handler you can access the parameter of type CommandEventArgs and inspect the value e.CommandName where e is the name of the CommandEventArgs parameter.
It can be used to have one handler method that does the work for more than one button or different jobs depending on your program flow.

Please read the example the following link points to, it's pretty clear:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.commandname.aspx


Cheers,


Manfred
 
Share this answer
 
v2
Comments
edyzakaria 14-Dec-10 22:24pm    
I've read that, thank you.
But still not for me. When i explore about the commandname in msdn i also arrived at there. but not the thing that i want.
in the example showing that e.commandname submit doing something. that is the thing that i want to know from commandname Login.
but i also have considering that my question might be quite sensitive since looks like the logic behind that commandname "login" is not open.

So if anybody out there know that it is a "closed logic/code" please inform me. :)
Manfred Rudolf Bihy 15-Dec-10 3:10am    
If you have acces to the code behind files for your application search it for LoginButton and look out for places where event handlers are getting hooked up especially OnClick and OnCommand. If you don't have access to the code behind files ... lots o' luck pal :)
_ZaiT_ 3-Jan-14 10:59am    
Hi
After I start browsing my asp.net code
<asp:button runat="server" commandname="Login" text="Log in" xmlns:asp="#unknown" />
in html it appear like this
<input type="submit" name="ctl00$MainContent$ctl00$ctl06" value="Log in" önclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$MainContent$ctl00$ctl06", "", true, "", "", false, false))" />
I can't understand how it works. Can anybody explain this?
Thank you.
CHill60 3-Jan-14 15:11pm    
By posting your question as a comment to a solution, only Manfred will be notified about it. To get the maximum number of people viewing your question you can use the Ask a Question link.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900