Master Page Button and Detail Page Button

M

Mark Olbert

I have a website (ASPNET2) where the master page has a button in it and my login page, which is a detail page of the master page,
also has a button (a login button).

Everything works fine if I enter my user ID and password and click the Login button. But if I hit the return key instead the master
page button gets invoked instead of the Login button.

Is there a way of ensuring the Login button on the detail page gets the "default" return key event rather than the master page?
Other than disabling the master key button, which I know will work.

- Mark
 
L

Luke Zhang [MSFT]

Hello,

To get around this problem, you may use a HTML INPUT button instead of
asp:Button control on the msater page. for example:

<input id="Button1" style="width: 107px; height: 49px" type="button"
value="button" runat="server" onserverclick="Button1_ServerClick" />

Asp:Button control will be rendered as Input Submit control in client
browser. When you press enter key in a textbox, the first Input Submit
control in a web page will be invoked.

Hope this help,

Luke
 
M

Mark Olbert

Luke,

I didn't mention that the button on the master page is an ImageButton control. Is there a simple way to force the ImageButton
control to not be rendered as a submit button?

- Mark
 
L

Luke Zhang [MSFT]

Hello,

To replace a ImageButton:

<img id="img1" src="p1.jpg" style="width: 97px; cursor: hand;"
runat="server" onclick="__doPostBack('img1','')" />

Notice there is no event handler function in the code behind now, we need
to handle the click event:

protected void Page_Load(object sender, EventArgs e)
{
if (Request.Form.AllKeys.Length > 0 &&
Request.Form["__EVENTTARGET"] == "img1")
{
//add button click handler here.
}
}


Luke
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top