views:

398

answers:

3

hi

I want to send a string to another page named Reply.aspx using the QueryString.

I wrote this code on first page that must send the text to Reply.aspx:

protected void FReplybtn_Click(object sender, EventArgs e)
{
    String s = "Reply.aspx?";
    s += "Subject=" + FSubjectlbl.Text.ToString();
    Response.Redirect(s);
}

I wrote this code on the Reply.aspx page:

RSubjectlbl.Text += Request.QueryString["Subject"];

But this approach isn't working correctly and doesn't show the text.

What should I do to solve this?

Thanks

A: 

Though your code should work fine, even if the source string has spaces etc. it should return something when you access query string, please try this also:

protected void FReplybtn_Click(object sender, EventArgs e)
{
    String s = Page.ResolveClientUrl("~/ADMIN/Reply.aspx");
    s += "?Subject=" + Server.UrlEncode(FSubjectlbl.Text.ToString());
    Response.Redirect(s);
}

EDIT:-

void Page_Load(object sender, EventArgs e)
{
    if(Request.QueryString.HasKeys())
    {
        if(!string.IsNullOrEmpty(Request.QueryString["Subject"]))
        {
            RSubjectlbl.Text += Server.UrlDecode(Request.QueryString["Subject"]);
        }
    }
}

PS:- Server.UrlEncode is also sugested in comment to this question.

TheVillageIdiot
when I want to use request for get string how do it?
mohammad reza
I've edited answer!
TheVillageIdiot
A: 

Sorry, I mis-read, please ignore this.

Erich
A: 

this is easy :

First page :

        string s = "~/ADMIN/Reply.aspx?";
        s += "Subject=" + FSubjectlbl.Text;
        Response.Redirect(s);

Second page :

        RSubjectlbl.Text = Request.QueryString["Subject"];
mohammad reza