Simulate linkbutton click on submit

G

Guest

I have two sets of search criteria on my page.
They are placed inside two DIV tags made visible/hidden by a client script.
In each DIV tag I have a LinkButton that performs the search from each set.

By using AJAX I get the resulting list expand and collapse without page
reload.
All work smoothly.

But one user today complained that the submit behaviour doesn't work like
before.
When hitting the ENTER key the LinkButton is NOT fired making a new search
based on the criteria. Instead the first node in the current repeater set is
expanded.

Can I decide that my LinkButton should be fired when the user is hitting his
ENTER button?
 
M

Mark Fitzpatrick

His problem may be that the focus has been set on the first item in the
repeater. You can search for scripts that will allow you to set focus on
ASP.Net objects. This would give you the ability to set focus on the enter
button right away. It could also be that the user is tabbing around before
getting to the linkbutton and thus has set the focus themselves on the first
row without realizing it.
 
W

Walter Wang [MSFT]

Hello,

Do you mean that when focus is on the LinkButton, press ENTER doesn't cause
the LinkButton's Click event gets fired on server?

If you mean that when the focus is in a INPUT field and you press ENTER,
based on my test, the LinkButton will not be "clicked" when you press ENTER
on a INPUT field, the form is submitted but the LinkButton is not clicked:

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

protected void LinkButton1_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
}

protected void LinkButton2_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:MultiView ActiveViewIndex=0 ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
View1<asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox>
<asp:LinkButton ID="LinkButton1" runat="server"
OnClick="LinkButton1_Click">LinkButton</asp:LinkButton></asp:View>
<asp:View ID="View2" runat="server">
View2<asp:TextBox ID="TextBox2"
runat="server"></asp:TextBox>
<asp:LinkButton ID="LinkButton2" runat="server"
OnClick="LinkButton2_Click">LinkButton</asp:LinkButton></asp:View>
</asp:MultiView>
<asp:Button ID="Button1" runat="server" Text="Button" /></div>
</form>
</body>
</html>


AJAX doesn't change much here: pressing ENTER will cause the form submit to
server, but the LinkButton's click event isn't fired.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

Walter Wang [MSFT]

Hi,

Have you seen my last reply? Please feel free to let me know if there's
anything unclear. Thanks.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top