P
Paul
I've written som junk code below to show a problem I'm getting:
On a page I've got a dropdownlist and a button using submit behaviour:
<aspropDownList ID="tester" runat="server" AutoPostBack="true"
EnableViewState="False"
OnSelectedIndexChanged="tester_SelectedIndexChanged">
<asp:ListItem Text="All" Value="ALL"></asp:ListItem>
<asp:ListItem Text="2" Value="2"></asp:ListItem>
<asp:ListItem Text="3" Value="3"></asp:ListItem>
<asp:ListItem Text="4" Value="4"></asp:ListItem>
<asp:ListItem Text="5" Value="5"></asp:ListItem>
</aspropDownList>
<asp:Button ID="Button1" runat="server" CausesValidation="False"
EnableViewState="False"
OnClick="Button1_Click" Text="Button" />
The codebehind looks like this:
public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["id"] != null)
tester.SelectedValue =
Request.QueryString["id"].ToString();
}
protected void tester_SelectedIndexChanged(object sender,
EventArgs e)
{
Response.Redirect("test.aspx?id=" +
Request.Form[tester.UniqueID]);
Response.End();
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("here");
}
}
Whats happening is that the selectedindexchanged event is causing a
redirect which is passing the value of the selected dropdownlist back
to the page, this is then used to select the listitem relating to the
ID. I know this is convoluted, but it's something I need to use as per
a client request.
My issue is that if the button is pressed before selectedindexchanged,
then the button click event is fired. If the selectedindexchnaged
event fires, then the button click event won't.
From looking at the html, it seems the postback and redirect is
causing the button behaviour to change from submit to text. This stops
the button click event from being fired.
Why is this occuring? And is there anything I can do to stop it from
happening? I've tried programatically changing the buttons submit
behaviour but it doesn't stop this problem from occuring.
On a page I've got a dropdownlist and a button using submit behaviour:
<aspropDownList ID="tester" runat="server" AutoPostBack="true"
EnableViewState="False"
OnSelectedIndexChanged="tester_SelectedIndexChanged">
<asp:ListItem Text="All" Value="ALL"></asp:ListItem>
<asp:ListItem Text="2" Value="2"></asp:ListItem>
<asp:ListItem Text="3" Value="3"></asp:ListItem>
<asp:ListItem Text="4" Value="4"></asp:ListItem>
<asp:ListItem Text="5" Value="5"></asp:ListItem>
</aspropDownList>
<asp:Button ID="Button1" runat="server" CausesValidation="False"
EnableViewState="False"
OnClick="Button1_Click" Text="Button" />
The codebehind looks like this:
public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["id"] != null)
tester.SelectedValue =
Request.QueryString["id"].ToString();
}
protected void tester_SelectedIndexChanged(object sender,
EventArgs e)
{
Response.Redirect("test.aspx?id=" +
Request.Form[tester.UniqueID]);
Response.End();
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("here");
}
}
Whats happening is that the selectedindexchanged event is causing a
redirect which is passing the value of the selected dropdownlist back
to the page, this is then used to select the listitem relating to the
ID. I know this is convoluted, but it's something I need to use as per
a client request.
My issue is that if the button is pressed before selectedindexchanged,
then the button click event is fired. If the selectedindexchnaged
event fires, then the button click event won't.
From looking at the html, it seems the postback and redirect is
causing the button behaviour to change from submit to text. This stops
the button click event from being fired.
Why is this occuring? And is there anything I can do to stop it from
happening? I've tried programatically changing the buttons submit
behaviour but it doesn't stop this problem from occuring.