Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

passing a querystring

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rodchar - 26 Oct 2007 17:21 GMT
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 - 26 Oct 2007 17:41 GMT
Hello,

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

--
Patrice

> hey all,
> i know i can do response.redirect("my.aspx?id=1")
[quoted text clipped - 4 lines]
> thanks,
> rodchar
David W - 27 Oct 2007 17:53 GMT
Use the viewstate collection or add a HiddenField.
Maximiliano - 27 Oct 2007 21:13 GMT
> hey all,
> i know i can do response.redirect("my.aspx?id=1")
[quoted text clipped - 3 lines]
> 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?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.