1

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

Ahmad Mageed
  • 94,561
  • 19
  • 163
  • 174
mohammad reza
  • 3,292
  • 6
  • 29
  • 39

2 Answers2

0

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
  • 40,053
  • 20
  • 133
  • 188
0

this is easy :

First page :

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

Second page :

RSubjectlbl.Text = Request.QueryString["Subject"];
Undo
  • 25,519
  • 37
  • 106
  • 129
mohammad reza
  • 3,292
  • 6
  • 29
  • 39