Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > passing a querystring

Reply
Thread Tools

passing a querystring

 
 
=?Utf-8?B?cm9kY2hhcg==?=
Guest
Posts: n/a
 
      10-26-2007
hey all,
i know i can do response.redirect("my.aspx?id=1")

but what if i'm doing a postback, is there something similar to querystring?

thanks,
rodchar
 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      10-26-2007
Hello,

Request.QueryString allows to read querystring parameters during a postback.
Is this what you are looking for ?

--
Patrice

"rodchar" <(E-Mail Removed)> a écrit dans le message de
news: http://www.velocityreviews.com/forums/(E-Mail Removed)...
> hey all,
> i know i can do response.redirect("my.aspx?id=1")
>
> but what if i'm doing a postback, is there something similar to
> querystring?
>
> thanks,
> rodchar



 
Reply With Quote
 
 
 
 
David W
Guest
Posts: n/a
 
      10-27-2007
Use the viewstate collection or add a HiddenField.


 
Reply With Quote
 
Maximiliano
Guest
Posts: n/a
 
      10-27-2007
On 26 oct, 13:21, rodchar <(E-Mail Removed)> wrote:
> hey all,
> i know i can do response.redirect("my.aspx?id=1")
>
> but what if i'm doing a postback, is there something similar to querystring?
>
> thanks,
> rodchar


Hi Rod
Sometimes when there is no another option I use this trick below
(there are two pages):

Page 1 : HiddenValue.aspx
---------------------------------------
<%@ Page Language="c#" Debug="true" %>
<%@ Import Namespace="System.Text" %>

<script language="c#" runat="server">
public void ButtonConfirmar1_Click (object sender, EventArgs e)
{
Hidden1.Value = TextBox1.Text.ToUpper();
Hidden2.Value = TextBox2.Text.ToUpper();

// javascript: watch out with the Form's name (here is Form1)
StringBuilder script = new StringBuilder();
script.AppendFormat("<script language='javascript'>");

script.AppendFormat("document.getElementById('Form 1').action='HiddenValueProcess.aspx';");
script.AppendFormat("document.forms[0].__VIEWSTATE.name =
'NOVIEWSTATE';");
script.AppendFormat("document.getElementById('Form 1').submit();</
script>");;

Page.RegisterStartupScript("submitForm", script.ToString());
}
</script>

<form id="Form1" method="post" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

<INPUT id="Hidden1" runat="server" type="hidden">
<INPUT id="Hidden2" runat="server" type="hidden">

<asp:Button ID="ButtonConfirmar1" runat="server" Text="Confirmar"
OnClick="ButtonConfirmar1_Click"/>
</form>

Page 1 : HiddenValueProcess.aspx
---------------------------------------------------
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
string value1 = Request.Form["Hidden1"].ToString();
string value2 = Request.Form["Hidden2"].ToString();

Response.Write("<p>Valor 1=" + value1);
Response.Write("<p>Valor 2=" + value2);
}
}

This is what are you looking for. aren't you?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is passing Querystring same as Hidden variable? Bobby Edward ASP .Net 3 01-23-2009 06:03 PM
Passing querystring parameters to Frameset -- How? news-server.maine.rr.com ASP .Net 1 02-06-2007 01:00 AM
How to get value of QueryString inside QueryString Mehdi ASP .Net 6 04-06-2006 03:41 PM
Passing QueryString URL as a paremeter in QueryString Adeel Ahmad ASP General 1 03-07-2006 02:05 PM
Select a row from a DataGrid1 by passing a QueryString variable David Dimmer ASP .Net Datagrid Control 0 04-20-2004 06:00 PM



Advertisments