473,699 Members | 2,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

postback issue

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:

<asp:DropDownLi st ID="tester" runat="server" AutoPostBack="t rue"
EnableViewState ="False"
OnSelectedIndex Changed="tester _SelectedIndexC hanged">
<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>
</asp:DropDownLis t>

<asp:Button ID="Button1" runat="server" CausesValidatio n="False"
EnableViewState ="False"
OnClick="Button 1_Click" Text="Button" />

The codebehind looks like this:

public partial class test : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
if (Request.QueryS tring["id"] != null)
tester.Selected Value =
Request.QuerySt ring["id"].ToString();
}
protected void tester_Selected IndexChanged(ob ject sender,
EventArgs e)
{
Response.Redire ct("test.aspx?i d=" +
Request.Form[tester.UniqueID]);
Response.End();
}
protected void Button1_Click(o bject sender, EventArgs e)
{
Response.Write( "here");
}
}
Whats happening is that the selectedindexch anged 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 selectedindexch anged,
then the button click event is fired. If the selectedindexch naged
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.



Jun 27 '08 #1
2 1401

"Paul" <Ge**********@g mail.comwrote in message
news:f9******** *************** ***********@2g2 000hsn.googlegr oups.com...
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:

<asp:DropDownLi st ID="tester" runat="server" AutoPostBack="t rue"
EnableViewState ="False"
OnSelectedIndex Changed="tester _SelectedIndexC hanged">
<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>
</asp:DropDownLis t>

<asp:Button ID="Button1" runat="server" CausesValidatio n="False"
EnableViewState ="False"
OnClick="Button 1_Click" Text="Button" />

The codebehind looks like this:

public partial class test : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
if (Request.QueryS tring["id"] != null)
tester.Selected Value =
Request.QuerySt ring["id"].ToString();
}
protected void tester_Selected IndexChanged(ob ject sender,
EventArgs e)
{
Response.Redire ct("test.aspx?i d=" +
Request.Form[tester.UniqueID]);
Response.End();
}
protected void Button1_Click(o bject sender, EventArgs e)
{
Response.Write( "here");
}
}
Whats happening is that the selectedindexch anged 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 selectedindexch anged,
then the button click event is fired. If the selectedindexch naged
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.
Perhaps if you described the requirement rather than the problem/solution it
would be easier to assist?
It sounds quite a convoluted procedure for what seems like a standard task.

--

Joe Fawcett (MVP - XML)

http://joe.fawcett.name
Jun 27 '08 #2
On 22 May, 08:50, "Joe Fawcett" <joefawc...@new sgroup.nospamwr ote:
"Paul" <Gef.Mongo...@g mail.comwrote in message

news:f9******** *************** ***********@2g2 000hsn.googlegr oups.com...
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:
<asp:DropDownLi st ID="tester" runat="server" AutoPostBack="t rue"
EnableViewState ="False"
OnSelectedIndex Changed="tester _SelectedIndexC hanged">
<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>
</asp:DropDownLis t>
* *<asp:Button ID="Button1" runat="server" CausesValidatio n="False"
EnableViewState ="False"
* * * *OnClick="Butto n1_Click" Text="Button" />
The codebehind looks like this:
public partial class test : System.Web.UI.P age
{
* *protected void Page_Load(objec t sender, EventArgs e)
* *{
* * * *if (Request.QueryS tring["id"] != null)
* * * * * *tester.Selecte dValue =
Request.QuerySt ring["id"].ToString();
* *}
* *protected void tester_Selected IndexChanged(ob ject sender,
EventArgs e)
* *{
* * * *Response.Redir ect("test.aspx? id=" +
Request.Form[tester.UniqueID]);
* * * *Response.End() ;
* *}
* *protected void Button1_Click(o bject sender, EventArgs e)
* *{
* * * *Response.Write ("here");
* *}
}
Whats happening is that the selectedindexch anged 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 selectedindexch anged,
then the button click event is fired. If the selectedindexch naged
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.

Perhaps if you described the requirement rather than the problem/solution it
would be easier to assist?
It sounds quite a convoluted procedure for what seems like a standard task..
The page in question is required to have javascript functionality, but
be perfectly usable for people with JS disabled - making use of the
query string to store search terms and the selected dropdownlist item
- this allows search terms to be saved as a link and pasted in emails
etc.
So a user with JS enabled can select a dropdownlist item and
autopostback will immediately update the search results (the
dropdownlist item will then be placed in the querystring - the reason
for the postback), but if a user doesn't have JS enabled, pressing the
search button (whose submit behaviour gets broken) will update the
query string etc.
Using Response.End() stops the page being re-rendered before the
redirect, which limits performance issues. There is no reason why .net
should change the button submittion behaviour though that I can see.
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4709
by: Rhys | last post by:
I have a page which has an IFrame on it. The src of the IFrame is a page with a datagrid on it. The Datagrid has bound template columns. The columns of the datagrid pass the bound data value of each cell within it to my code behind file which generates the HTML to display the data in a formatted text box, some of which is editable, some of which is not. The idea here is that the user can look at a page with a scrolling 'window'. Move...
7
1845
by: Anand | last post by:
Hi All, The postback on my desktop stopped working. I am trying to run the webapplication locally on my desktop and the Postback on my home page won't trigger on any of my dropdown selections. The error on the displayed HTML points to the line in the PostBack event which is not my code but the auto generated code for the postback event. Have anybody else faced this issue. Any help appreciated. Thanks Anand
5
2426
by: Tom Anderson | last post by:
I am currently having an issue with an ASP.Net 1.1 Web page that does the following remotely but not locally. Click on a control Check for postback, if postback, handle the event, otherwise populate page with options. What is happening is that remotely the page is doing a double postback, then doing a post without data at all resulting in the event being fired twice, then redirecting to the incorrect option in a dropdown (going to...
2
620
by: Wizzard | last post by:
I have a repeater with and imagebutton on a page useing VS2005 ASP.Net 2.0 <asp:Repeater ID="Repeater1" runat="server" > <ItemTemplate> <div> <asp:ImageButton ImageUrl="button.gif" ID="ImageButton1" runat="server" /> <p><%# Eval("Name") %></p> </div> </ItemTemplate>
1
1371
by: Jason | last post by:
I have a webpage that I've wrapped in an Atlas UpdatePanel. This page contains four textboxes, each with AutoPostBack set to true. The problem comes when someone edits the first box and tabs to the second box. They have enough time to make a quick edit to the second box before the postback completes and then the value in the second textbox is reset to the original value. Is there anything I can do about this? It's really causing...
3
2752
by: teo | last post by:
Mozilla error on postback and validation ----------- A Button causes a Listbox to desappear. If no item has been selected on the Listbox, all is OK. If one or more items are selected,
11
14819
by: antonyliu2002 | last post by:
I know that this has been asked and answered thousands of times. As a matter of fact, I know that I need to say If Not Page.IsPostBack Then 'Do something End If for things that needs to be processed by the web server. I am still struggling to understand this postback logic, and hope that some kind gurus out there could help me clarify the confusion I have.
6
2902
by: Dmitry Duginov | last post by:
Hi, I have the following label markup (label is inside FormView): <asp:Label ID="lblIndicatorReady" runat="server" Text="RE" ToolTip="Ready" BackColor='<%# Eval("Ready").ToString()=="True"?System.Drawing.Color.FromName("#FFFF80"):System.Drawing.Color.White %>' Enabled='<%# Eval("Ready") %>'
2
2094
by: =?Utf-8?B?SlA=?= | last post by:
Hi all. I'm having a problem with a postback issue and I think it's cache related. Here's my setup: I have a web site that has a signup section. This has simple things like name, age, birth date, etc. When the user visits this page for the first time, a person's data object that is used to store the user's name, age, birth date, etc. is created and stored in session. On the first visit to this page, the object is empty. Whenever the...
4
1498
by: Doogie | last post by:
Basically, I have two custom dates the user can enter via a popup calendar. These dates are stored into text boxes. Then the user can click a button (Run Report) and those values (as well as others) are used to build an SRS url string. This used to work before I modified the page to make the calendar a popup. Now, the text boxes lose their value when the user clicks the run report button. I have verified this is happening because...
0
8612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7743
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2342
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.