473,506 Members | 9,749 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Postback nightmares

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 it’s doing a
postback, but the values are gone before page_load is called. I have
EnableViewState set to true for both text boxes and it’s not retaining
the values. I have tried variations of ways to fix this (set the
values in a view state object, enable view state on the page as a
whole, etc) and nothing is working.

Am I missing something?
Jun 27 '08 #1
4 1491
It sound like you are capturing the entered values from the popup
client-side, and therefore there is no server-side TextChanged event or
ViewState populated.
Of course, when the postback is created, you get two empty textboxes because
valuess populated in the browser don't get transmitted. Among other tricks,
you could try storing them in a cookie first - that can be done client-side
via javascript. Then read back the cookie on a postback and you can get your
values.
Peter

"Doogie" <dn******@dtgnet.comwrote in message
news:03**********************************@27g2000h sf.googlegroups.com...
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 it’s doing a
postback, but the values are gone before page_load is called. I have
EnableViewState set to true for both text boxes and it’s not retaining
the values. I have tried variations of ways to fix this (set the
values in a view state object, enable view state on the page as a
whole, etc) and nothing is working.

Am I missing something?

Jun 27 '08 #2
On May 1, 10:38*am, "Peter Bromberg [C# MVP]"
<pbromb...@nospammin.yahoo.comwrote:
It sound like you are capturing the entered values from the popup
client-side, and therefore there is no server-side TextChanged event or
ViewState populated.
Of course, when the postback is created, you get two empty textboxes because
valuess populated in the browser don't get transmitted. Among other tricks,
you could try storing them in a cookie first - that can be done client-side
via javascript. Then read back the cookie on a postback and you can get your
values.
Peter

"Doogie" <dnlwh...@dtgnet.comwrote in message

news:03**********************************@27g2000h sf.googlegroups.com...
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 it’s doing a
postback, but the values are gone before page_load is called. *I have
EnableViewState set to true for both text boxes and it’s not retaining
the values. *I have tried variations of ways to fix this (set the
values in a view state object, enable view state on the page as a
whole, etc) and nothing is working.

Am I missing something?
Turns out that the fact the text boxes are disabled is what is causing
the issue. Setting them to be enabled fixed the issue. Weird, not
sure why I wouldn't be able to do that. I have them disabled cause I
wanted them to only be filled by the calendar popup and not manually
entered.
Jun 27 '08 #3
"Doogie" <dn******@dtgnet.comwrote in message
news:c5**********************************@34g2000h sf.googlegroups.com...
Turns out that the fact the text boxes are disabled is what is causing
the issue. Setting them to be enabled fixed the issue. Weird, not
sure why I wouldn't be able to do that. I have them disabled cause I
wanted them to only be filled by the calendar popup and not manually
entered.
Aha! I've seen that before.

Had you disabled the textboxes in the actual markup i.e. in the <asp:TextBox
tag?
If so, try disabling them in codebehind e.g.

TextBox1.Enabled = false;

or even

TextBox1.Attributes.Add("disabled", "disabled");
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #4
Hi,

You could set submitdisabledcontrols="true" on the <formelement of the
page which makes asp.net to post also disabled textboxes values. I believe
disabled HTML form elements don't submit by default.

Other option is to set TextBox as readonly but that has to be done via
Attributes.Add
(http://aspadvice.com/blogs/joteke/ar.../12/16409.aspx) as setting
ReadOnly property prevents postback data from being loaded, meaning in
practise that TextBox doesn't keep its state (it's read-only from
server-side perspective)
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
"Doogie" <dn******@dtgnet.comwrote in message
news:c5**********************************@34g2000h sf.googlegroups.com...
On May 1, 10:38 am, "Peter Bromberg [C# MVP]"
<pbromb...@nospammin.yahoo.comwrote:
It sound like you are capturing the entered values from the popup
client-side, and therefore there is no server-side TextChanged event or
ViewState populated.
Of course, when the postback is created, you get two empty textboxes
because
valuess populated in the browser don't get transmitted. Among other
tricks,
you could try storing them in a cookie first - that can be done
client-side
via javascript. Then read back the cookie on a postback and you can get
your
values.
Peter

"Doogie" <dnlwh...@dtgnet.comwrote in message

news:03**********************************@27g2000h sf.googlegroups.com...
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 it’s doing a
postback, but the values are gone before page_load is called. I have
EnableViewState set to true for both text boxes and it’s not retaining
the values. I have tried variations of ways to fix this (set the
values in a view state object, enable view state on the page as a
whole, etc) and nothing is working.

Am I missing something?
Turns out that the fact the text boxes are disabled is what is causing
the issue. Setting them to be enabled fixed the issue. Weird, not
sure why I wouldn't be able to do that. I have them disabled cause I
wanted them to only be filled by the calendar popup and not manually
entered.
Jun 27 '08 #5

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

Similar topics

5
2032
by: Matthew Louden | last post by:
I created simple ASP.NET web application to test how AutoPostBack property in a web control works. I set AutoPostBack property to be true of a web control. When I run the application, here's the...
2
4313
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
8
11137
by: walesboy | last post by:
greetings - I have a btnSubmit button with a Handles btnSubmit.click which works great if all the user does is click that button. But, if the user ALSO changes a text box on the page (which...
4
3380
by: Jim Hammond | last post by:
It would be udeful to be able to get the current on-screen values from a FormView that is databound to an ObjectDataSource by using a callback instead of a postback. For example: public void...
1
17021
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater...
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"...
11
14789
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...
7
3350
by: Tony Girgenti | last post by:
Hello. I'm trying to undetrstand ASP.NET 2.0 and javascript. When i have a button and i click on it and i see the web broswer progress bar at the bottom do something, does that mean that there...
2
3899
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
0
7220
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7105
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...
0
7308
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,...
0
7371
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...
0
7479
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1534
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 ...
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
410
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.