Search code examples
c#asp.netstringresponse.write

Reponse.Write output in another aspx page


I have below page_load method on one aspx page. Now, I want to get string xmlData in another aspx page in string variable. is there a way that i can get the value of xmlData variable on another page?

protected void Page_Load(object sender, System.EventArgs e)
        {
            string xmlData = "text for this example"
            Response.Write(xmlData);
        }

Solution

  • It worked for me with below code -

    StringWriter writer = new StringWriter();
    Server.Execute("/page1.aspx", writer);
    

    Now, writer has value which was written in xmlData variable in page1.aspx.

    Thank you guys for your time.