Saturday, March 31, 2012
Text box losing most recent Text value
the total fees the registrant will incur and puts it in a textbox (not a
label because it has to be passed to another page).
txtTotalFees.Text = Format(dblTotalFees, "Currency")
The subroutine works fine IF I call it from PageLoad, or I assign it to a
button for recalculating the total fees, or the user clicks the Reset
button, or if they click a control that has AutoPostback set to true.
Basically anything that loads or postbacks the page.
BUT...When it comes time to submit the page and go to the next page I have
this code:
If IsValid Then
CalcFees() 'recalcs fees and updates textbox
Server.Transfer("Confirmation.aspx", True)
End If
When the user gets to the next page I put the total fees in another textbox.
EXCEPT it isn't updated to most recent total. I know because I can comment
out the "Server.Transfer" so that it stays at the registration page AND THE
CORRECT TOTAL IS DISPLAYED!?!?!
What is it about the Server.Transfer that "forgets" what the value of the
textbox should be?
Ken "BiggMakk" McCroryHi Ken
Try this:
Server.Transfer("Confirmation.aspx", True)
This sets the parameter preserveForm to true, hence preserving any
variables still available.
You can then retrieve the value from your previous page on the
Confirmation.aspx page by using Request.Form("totalFees")
Hope that helps :)
sze
Thanks for the try but I am already using the True to preserve variables.
(See original post. It's there.)
Ken "BiggMakk" McCrory
"sze" <szeying.tan@.gmail.com> wrote in message
news:1110401185.776188.29550@.o13g2000cwo.googlegroups.com...
> Hi Ken
> Try this:
> Server.Transfer("Confirmation.aspx", True)
> This sets the parameter preserveForm to true, hence preserving any
> variables still available.
> You can then retrieve the value from your previous page on the
> Confirmation.aspx page by using Request.Form("totalFees")
> Hope that helps :)
> sze
>
Ah, sorry. I didn't notice it in your code at first glance.
Here's a helpful page from MSDN about preserving state between pages.
http://msdn.microsoft.com/library/d...etweenPages.asp
Hope that helps.
I solved this by using SmartNavigation and turning on Autopostback for every
control that can affect the total fees. Before someone says SmartNav doesn't
work in browsers other than IE, you're right. Someone else in a different
post of mine pointed out Smart Scroller by Strength Technologies at this web
site:
http://www.strengthtechnologies.com...l/Download.aspx
It works even in Firefox.
Now the Total fees gets updated before the user hits the Submit button and
the correct value gets passed to the next page. It also removes the need for
the manual "Recalculate Fees" button that I had on the page.
--
Ken "BiggMakk" McCrory
"Ken McCrory" <klm355t@.removefornospammers.smsu.edu> wrote in message
news:OjfvdfOJFHA.688@.TK2MSFTNGP10.phx.gbl...
> It's me and my registration page again. I have a subroutine that
> calculates the total fees the registrant will incur and puts it in a
> textbox (not a label because it has to be passed to another page).
> txtTotalFees.Text = Format(dblTotalFees, "Currency")
> The subroutine works fine IF I call it from PageLoad, or I assign it to a
> button for recalculating the total fees, or the user clicks the Reset
> button, or if they click a control that has AutoPostback set to true.
> Basically anything that loads or postbacks the page.
> BUT...When it comes time to submit the page and go to the next page I have
> this code:
> If IsValid Then
> CalcFees() 'recalcs fees and updates textbox
> Server.Transfer("Confirmation.aspx", True)
> End If
> When the user gets to the next page I put the total fees in another
> textbox. EXCEPT it isn't updated to most recent total. I know because I
> can comment out the "Server.Transfer" so that it stays at the registration
> page AND THE CORRECT TOTAL IS DISPLAYED!?!?!
> What is it about the Server.Transfer that "forgets" what the value of the
> textbox should be?
> Ken "BiggMakk" McCrory
>
Yeah Ken the control works with FireFox and I.E!!!
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!
Text box losing most recent Text value
the total fees the registrant will incur and puts it in a textbox (not a
label because it has to be passed to another page).
txtTotalFees.Text = Format(dblTotalFees, "Currency")
The subroutine works fine IF I call it from PageLoad, or I assign it to a
button for recalculating the total fees, or the user clicks the Reset
button, or if they click a control that has AutoPostback set to true.
Basically anything that loads or postbacks the page.
BUT...When it comes time to submit the page and go to the next page I have
this code:
If IsValid Then
CalcFees() 'recalcs fees and updates textbox
Server.Transfer("Confirmation.aspx", True)
End If
When the user gets to the next page I put the total fees in another textbox.
EXCEPT it isn't updated to most recent total. I know because I can comment
out the "Server.Transfer" so that it stays at the registration page AND THE
CORRECT TOTAL IS DISPLAYED!?!?!
What is it about the Server.Transfer that "forgets" what the value of the
textbox should be?
Ken "BiggMakk" McCroryHi Ken
Try this:
Server.Transfer("Confirmation.aspx", True)
This sets the parameter preserveForm to true, hence preserving any
variables still available.
You can then retrieve the value from your previous page on the
Confirmation.aspx page by using Request.Form("totalFees")
Hope that helps :)
sze
Thanks for the try but I am already using the True to preserve variables.
(See original post. It's there.)
Ken "BiggMakk" McCrory
"sze" <szeying.tan@.gmail.com> wrote in message
news:1110401185.776188.29550@.o13g2000cwo.googlegro ups.com...
> Hi Ken
> Try this:
> Server.Transfer("Confirmation.aspx", True)
> This sets the parameter preserveForm to true, hence preserving any
> variables still available.
> You can then retrieve the value from your previous page on the
> Confirmation.aspx page by using Request.Form("totalFees")
> Hope that helps :)
> sze
Ah, sorry. I didn't notice it in your code at first glance.
Here's a helpful page from MSDN about preserving state between pages.
http://msdn.microsoft.com/library/d...etweenPages.asp
Hope that helps.
I solved this by using SmartNavigation and turning on Autopostback for every
control that can affect the total fees. Before someone says SmartNav doesn't
work in browsers other than IE, you're right. Someone else in a different
post of mine pointed out Smart Scroller by Strength Technologies at this web
site:
http://www.strengthtechnologies.com...l/Download.aspx
It works even in Firefox.
Now the Total fees gets updated before the user hits the Submit button and
the correct value gets passed to the next page. It also removes the need for
the manual "Recalculate Fees" button that I had on the page.
--
Ken "BiggMakk" McCrory
"Ken McCrory" <klm355t@.removefornospammers.smsu.edu> wrote in message
news:OjfvdfOJFHA.688@.TK2MSFTNGP10.phx.gbl...
> It's me and my registration page again. I have a subroutine that
> calculates the total fees the registrant will incur and puts it in a
> textbox (not a label because it has to be passed to another page).
> txtTotalFees.Text = Format(dblTotalFees, "Currency")
> The subroutine works fine IF I call it from PageLoad, or I assign it to a
> button for recalculating the total fees, or the user clicks the Reset
> button, or if they click a control that has AutoPostback set to true.
> Basically anything that loads or postbacks the page.
> BUT...When it comes time to submit the page and go to the next page I have
> this code:
> If IsValid Then
> CalcFees() 'recalcs fees and updates textbox
> Server.Transfer("Confirmation.aspx", True)
> End If
> When the user gets to the next page I put the total fees in another
> textbox. EXCEPT it isn't updated to most recent total. I know because I
> can comment out the "Server.Transfer" so that it stays at the registration
> page AND THE CORRECT TOTAL IS DISPLAYED!?!?!
> What is it about the Server.Transfer that "forgets" what the value of the
> textbox should be?
> Ken "BiggMakk" McCrory
Yeah Ken the control works with FireFox and I.E!!!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Wednesday, March 28, 2012
text box value does not match value on postback
I have a text box that is currently being set by a javascript function
as a running total. the javascript is working fine, as values are
changing the running total is being set correctly in the text box.
When the page is posted to the button OnClick event, the value of the
text box is what was previously defaulted as part of the Page_Load
event.
Any ideas on what is happening here or how to fix this issue?
Thanks ALOT in advance.<allan.palmer@.cit.comwrote in message
news:9726ad9f-9d5a-4c98-8473-01645482697b@.e4g2000hsg.googlegroups.com...
Quote:
Originally Posted by
Any ideas on what is happening here or how to fix this issue?
Show your code...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
<allan.palmer@.cit.comwrote in message
news:9726ad9f-9d5a-4c98-8473-01645482697b@.e4g2000hsg.googlegroups.com...
Quote:
Originally Posted by
Hi All,
>
I have a text box that is currently being set by a javascript function
as a running total. the javascript is working fine, as values are
changing the running total is being set correctly in the text box.
When the page is posted to the button OnClick event, the value of the
text box is what was previously defaulted as part of the Page_Load
event.
>
Any ideas on what is happening here or how to fix this issue?
>
Thanks ALOT in advance.
Hi Allan,
The "problem" is that the POST value of the textbox is set *before*
Page_Load, then you are putting a default value in there during Page_Load
(overwriting the POST value), then your button click event is fired and you
see the Page_Load value instead of the POST value.
In your Page_Load, only set the default value of the textbox on the initial
page load:
if (!IsPostBack)
{
// Set default value.
}
text box value does not match value on postback
I have a text box that is currently being set by a javascript function
as a running total. the javascript is working fine, as values are
changing the running total is being set correctly in the text box.
When the page is posted to the button OnClick event, the value of the
text box is what was previously defaulted as part of the Page_Load
event.
Any ideas on what is happening here or how to fix this issue?
Thanks ALOT in advance.<allan.palmer@.cit.com> wrote in message
news:9726ad9f-9d5a-4c98-8473-01645482697b@.e4g2000hsg.googlegroups.com...
> Any ideas on what is happening here or how to fix this issue?
Show your code...
Mark Rae
ASP.NET MVP
http://www.markrae.net
<allan.palmer@.cit.com> wrote in message
news:9726ad9f-9d5a-4c98-8473-01645482697b@.e4g2000hsg.googlegroups.com...
> Hi All,
> I have a text box that is currently being set by a javascript function
> as a running total. the javascript is working fine, as values are
> changing the running total is being set correctly in the text box.
> When the page is posted to the button OnClick event, the value of the
> text box is what was previously defaulted as part of the Page_Load
> event.
> Any ideas on what is happening here or how to fix this issue?
> Thanks ALOT in advance.
Hi Allan,
The "problem" is that the POST value of the textbox is set *before*
Page_Load, then you are putting a default value in there during Page_Load
(overwriting the POST value), then your button click event is fired and you
see the Page_Load value instead of the POST value.
In your Page_Load, only set the default value of the textbox on the initial
page load:
if (!IsPostBack)
{
// Set default value.
}
text controls, when they change update the total control
<td width="130" style="WIDTH: 130px">Mastercard
</td>
<td width="21" style="WIDTH: 21px"><INPUT onkeypress="return(currencyFormatCents(this,',','.','$',event))" id="Mastercard" type="text" name="Mastercard" runat="server" style="WIDTH: 116px; HEIGHT: 22px" size="14"></td>
When This control, or any of the other 4 I want to update a label control with their total (all 4 added together).
<DIV id=TotalCreditCards
style="DISPLAY: inline; WIDTH: 70px; HEIGHT: 15px"
ms_positioning="FlowLayout"></DIV></TD>
Thank you for any helpI would put a routine in the onkeypress method to add the values together and display them on the label.
What if I have a routine already in the onkeypress, how can I add another one. Or is there a method for when you leave the text field?
Please take a look at this code. I get 'object expected' error on the page as soon as I update the Lottery text field that does onblur="CreateTotal" If I take out it out then I do not get the error.
Dim Section1Total as Decimal
Sub CreateTotal()
Section1Total = Lottery.Value + DriveOff.Value + drawer.Value + Other.Value
page.DataBind
End sub
If the below text field changes then I want Section1Total to be updated.
<INPUT onblur="CreateTotal" onkeypress="return(currencyFormatCents(this,',','.','$',event))" id="Lottery" type="text" name="Lottery" runat="server" style="WIDTH: 116px; HEIGHT: 22px" size="14"></TD>
Then this is the label that Section1Total goes into:
<asp:label id="Total" runat="server"
Text= '<%# Section1Total %>' Width="110px" Height="13px">
Change this:
Sub CreateTotal()
Section1Total = Lottery.Value + DriveOff.Value + drawer.Value + Other.Value
page.DataBind
End sub
To:
Sub CreateTotal(ByVal sender As System.Object, ByVal e As System.EventArgs)
Section1Total = Lottery.Value + DriveOff.Value + drawer.Value + Other.Value
page.DataBind
End sub
Then try executing hte onblur="CreateTotal" again.
And make sure you declared all your form variables properly:
Lottery.Value + DriveOff.Value + drawer.Value + Other.Value
I am assuming they are textbox controls, so they need to be declared by using:
Protected WithEvents DriveOff As System.Web.UI.WebControls.TextBox
Protected WithEvents Lottery As System.Web.UI.WebControls.TextBox
Protected WithEvents drawer As System.Web.UI.WebControls.TextBox
Protected WithEvents OtherAs System.Web.UI.WebControls.TextBox
HTH
Ah, just noticed you were using an HTML text control and not a web control. In that case you must declare them by using the following:
Protected WithEvents DriveOff As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents Lottery As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents drawer As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents OtherAs As System.Web.UI.HtmlControls.HtmlInputText
It already said that my HTML text controls were declared, so I did not include those lines of code but the rest I did word for word. I even added a button and have the onclick="CreateTotal"
Here is my vbscript
Sub CreateTotal(ByVal sender As System.Object, ByVal e As System.EventArgs)
Section1Total = Lottery.Value + DriveOff.Value + drawer.Value + Other.Value
page.DataBind
End sub
and the other Lottery control has
<INPUT onblur="CreateTotal" onkeypress="return(currencyFormatCents(this,',','.','$',event))" id="Lottery" style="WIDTH: 116px; HEIGHT: 22px" type="text" size="14" value="0" name="Lottery" runat="server"></TD>
When I click off Lottery textbox I get
Line: 507
Char: 1
Error 'CreateTotal' is undefined
when I click on the button I get the same error. Line 507 - doesn't not point to the correct place where 'CreateTotal' was called.
Thanks for the suggestions, any other ideas.
Can you post line 507?