passing a querystring

Discussion in 'ASP .Net' started by =?Utf-8?B?cm9kY2hhcg==?=, Oct 26, 2007.

  1. 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
     
    =?Utf-8?B?cm9kY2hhcg==?=, Oct 26, 2007
    #1
    1. Advertising

  2. =?Utf-8?B?cm9kY2hhcg==?=

    Patrice Guest

    Hello,

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

    --
    Patrice

    "rodchar" <> a écrit dans le message de
    news: ...
    > 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
     
    Patrice, Oct 26, 2007
    #2
    1. Advertising

  3. =?Utf-8?B?cm9kY2hhcg==?=

    David W Guest

    Use the viewstate collection or add a HiddenField.
     
    David W, Oct 27, 2007
    #3
  4. =?Utf-8?B?cm9kY2hhcg==?=

    Maximiliano Guest

    On 26 oct, 13:21, rodchar <> 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('Form1').action='HiddenValueProcess.aspx';");
    script.AppendFormat("document.forms[0].__VIEWSTATE.name =
    'NOVIEWSTATE';");
    script.AppendFormat("document.getElementById('Form1').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?
     
    Maximiliano, Oct 27, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mehdi
    Replies:
    6
    Views:
    36,261
    sloan
    Apr 6, 2006
  2. news-server.maine.rr.com

    Passing querystring parameters to Frameset -- How?

    news-server.maine.rr.com, Feb 6, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    791
    Frank Milverckowitz
    Feb 6, 2007
  3. Bobby Edward
    Replies:
    3
    Views:
    1,325
    Bobby Edward
    Jan 23, 2009
  4. David Dimmer

    Select a row from a DataGrid1 by passing a QueryString variable

    David Dimmer, Apr 20, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    144
    David Dimmer
    Apr 20, 2004
  5. Adeel Ahmad
    Replies:
    1
    Views:
    586
    Anthony Jones
    Mar 7, 2006
Loading...

Share This Page