T
tshad
I have a page with 2 buttons and was told I could get my choice of button to
act as the default button but add the following code to the my Page_Load:
Page.RegisterHiddenField("__EVENTTARGET", "btnSearch")
I have the following code and page:
****************************************************
<script runat="server">
Sub Page_Load(s as Object, e as EventArgs)
if not IsPostBack then
Page.RegisterHiddenField("__EVENTTARGET", "Button2")
end if
end sub
Sub Button1_Click(s as Object, e as EventArgs)
Label1.Text = "From Button 1"
end Sub
Sub Button2_Click(s as Object, e as EventArgs)
Label1.Text = "From Button 2"
end Sub
</script>
<form runat="server">
<table width="851" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>_
<asp:Label ID="Label1" runat="server" />
</tr>
<tr>
<td> </td>
</tr>
</table>
<asp:Button ID="Button1" Text="Button1" OnClick="Button1_Click"
runat="server" />
<asp:Button ID="Button2" Text="Button2" OnClick="Button2_Click"
runat="server" />
</form>
********************************************************************************************************************************
But it doesn't do anything until I press one of the buttons with my mouse or
tab to a button.
Is there a way to get this to work?
Thanks,
Tom
act as the default button but add the following code to the my Page_Load:
Page.RegisterHiddenField("__EVENTTARGET", "btnSearch")
I have the following code and page:
****************************************************
<script runat="server">
Sub Page_Load(s as Object, e as EventArgs)
if not IsPostBack then
Page.RegisterHiddenField("__EVENTTARGET", "Button2")
end if
end sub
Sub Button1_Click(s as Object, e as EventArgs)
Label1.Text = "From Button 1"
end Sub
Sub Button2_Click(s as Object, e as EventArgs)
Label1.Text = "From Button 2"
end Sub
</script>
<form runat="server">
<table width="851" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>_
<asp:Label ID="Label1" runat="server" />
</tr>
<tr>
<td> </td>
</tr>
</table>
<asp:Button ID="Button1" Text="Button1" OnClick="Button1_Click"
runat="server" />
<asp:Button ID="Button2" Text="Button2" OnClick="Button2_Click"
runat="server" />
</form>
********************************************************************************************************************************
But it doesn't do anything until I press one of the buttons with my mouse or
tab to a button.
Is there a way to get this to work?
Thanks,
Tom