Click here to Skip to main content
15,898,988 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friend.

I have one button control,one image button, one link button and one dropdownlist which has AutoPostBack=true.

When I run page, controls are render as following ways.

<input type="submit" name="Button1" value="Click" id="Button1" />
    <input type="image" name="btnImage" id="btnImage" src="images/addthis.gif" style="border-width:0px;" />
    
    <select name="drp" onchange="javascript:setTimeout('__doPostBack(\'drp\',\'\')', 0)" id="drp">
</select>
    
<a id="lnk" href="javascript:__doPostBack('lnk','')">Link</a>


Now, You can see in above code that dropdownlist and link button are render with __doPostBack function which is handle its event. but button control or image control does not have any function or control to handle event.

So my question is that If I put more than 10 button and image button so how page identify which button is clicked and raised particular event?

Thanks
Imrankhan
Posted
Updated 3-May-10 19:59pm
v3

By default, a Button control is a Submit button. A Submit button does not have a command name (specified by the CommandName property) associated with the button and simply posts the Web page back to the server. You can provide an event handler for the Click event to programmatically control the actions performed when the Submit button is clicked.

Please read this for more details: MSDN: Button Class[^]
 
Share this answer
 
Dear,

Although I couldn't understand your purpose, but if you want to know on server which button was clicked on client PC, you can use
<asp:Button ID="btn" Text="ClickMe" OnClientClick="__doPostBack(this.id, null)" runat="server" />

and on the server you can use:
VB
If Request("__EVENTTARGET") = btn.ClientID Then
     'Do Something ...
End If


Thanks
 
Share this answer
 
v2

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