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
  • 91,579
  • 18
  • 159
  • 169
mohammad reza
  • 3,092
  • 6
  • 28
  • 38

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
  • 38,965
  • 20
  • 129
  • 186
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,381
  • 37
  • 106
  • 126
mohammad reza
  • 3,092
  • 6
  • 28
  • 38