Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server.Transfer problem

Status
Not open for further replies.

Naoise

Programmer
Dec 23, 2004
318
IE
I have a form which has a link which in turn has an associated serverclick event. When this serverclick event is fired it sets the hidden value of the form and then uses server.transfer to send you to another page. However I am getting an error as the hidden field value does not seem to be set even though I check just before the server.transfer and the value is set. Any help appreciated.


==================================
ASPX page
==================================
<form id="frmMyForm" enctype="multipart/form-data" runat="server">
<input type="hidden" id="hdnMode" name="hdnMode" runat="server">
...
<a href="myPage.aspx" id="RedirectLink" runat="server">
</form>



===================================
CODE BEHIND PAGE
===================================
Sub RedirectLink_Click(ByVal Sender As Object, ByVal e As EventArgs) Handles RedirectLink.ServerClick
hdnMode.Value = "foo"
Server.Transfer("myPage.aspx",True)
End Sub



=================================
myPage.aspx
=================================
If(Request.Form("hdnMode") = "foo") Then



ERROR
Input string was not in a correct format.

 
jben is correct; might want to provide line where code breaks.

I do have a question. Usually I use a simplle Response.Redirect statement sending the value via QueryString, e.g.:

Code:
Response.Redirect(mypage.aspx?myValue='" & hdnMode.Value & "'")

And on the recieving page you'd have:
Code:
If(Request.QueryString("myValue") = "foo") Then
   ' do something
End If

I have not taken advantage of Server.Transfer so not familiar with it (so could be missing something here). It looks as if by sending the entire page (page's form) the request page captures all objects. This seems a little much for transferring a simple value. Briefly, what might be the advantage and disadvantage of using Server.Transfer v. Response.Redirect (with QS)?
 
Good point by Isadore, the Server.Transfer maybe overkill for what you want to do.

Jim
 
The error is on the myPage.aspx on the line provided ie

=================================
myPage.aspx
=================================
If(Request.Form("hdnMode") = "foo") Then

Overkill issues aside (but take on board) any suggestions as to why this might be happening?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top