locked
Date in UrlString RRS feed

  • Question

  • User-2051275383 posted

    Hey guys,

    What is the best way to use the UrlString to input a date? I want to use that value from a form into another page..

    Cheers!

    Sunday, November 9, 2014 9:38 PM

Answers

  • User2103319870 posted

    You can pass the value from one page another page using the QueryString

    Please see the sample implemenation

    Your PageA.aspx

    You can pass value to pageB like given below

    protected void btnRedirect_Click(object sender, EventArgs e)
            {
                //Pass the datevalue as Query string
                Response.Redirect("YourPageB.aspx?PassingValue=" + "11/10/2014");
            }

    YourPageB.aspx(Receiver Page)
    You can read the value passed through query string like given below

      //Read the values from Query string
                string value = Request.QueryString["PassingValue"].ToString();

    2) Using Session

    An Easy solution is to use Session and it will be like this

    Your PageA.aspx

               //Set the value of Textbox to session
                Session["Data"] = "11/10/2014";
    //Perform your Redirect Response.Redirect("YourPageB.aspx");

    YourPageB.aspx(Receiver Page)

    You can read values from session like given below

                if (!String.IsNullOrEmpty(Session["Data"].ToString()))
                {
    
                    //Read values from session
                    string valueA = Session["Data"].ToString();
    
                }

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 9, 2014 9:54 PM

All replies

  • User2103319870 posted

    You can pass the value from one page another page using the QueryString

    Please see the sample implemenation

    Your PageA.aspx

    You can pass value to pageB like given below

    protected void btnRedirect_Click(object sender, EventArgs e)
            {
                //Pass the datevalue as Query string
                Response.Redirect("YourPageB.aspx?PassingValue=" + "11/10/2014");
            }

    YourPageB.aspx(Receiver Page)
    You can read the value passed through query string like given below

      //Read the values from Query string
                string value = Request.QueryString["PassingValue"].ToString();

    2) Using Session

    An Easy solution is to use Session and it will be like this

    Your PageA.aspx

               //Set the value of Textbox to session
                Session["Data"] = "11/10/2014";
    //Perform your Redirect Response.Redirect("YourPageB.aspx");

    YourPageB.aspx(Receiver Page)

    You can read values from session like given below

                if (!String.IsNullOrEmpty(Session["Data"].ToString()))
                {
    
                    //Read values from session
                    string valueA = Session["Data"].ToString();
    
                }

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 9, 2014 9:54 PM
  • User-1716253493 posted
    Response.Redirect("page.aspx?date=10112014");
            if (Request.QueryString["date"] != null)
            {
               DateTime dt = DateTime.ParseExact(Request.QueryString["date"], "ddMMyyyy", null);
            }



    Sunday, November 9, 2014 11:13 PM
  • User-2051275383 posted

    You can pass the value from one page another page using the QueryString

    Please see the sample implemenation

    Your PageA.aspx

    You can pass value to pageB like given below

    protected void btnRedirect_Click(object sender, EventArgs e)
            {
                //Pass the datevalue as Query string
                Response.Redirect("YourPageB.aspx?PassingValue=" + "11/10/2014");
            }

    YourPageB.aspx(Receiver Page)
    You can read the value passed through query string like given below

      //Read the values from Query string
                string value = Request.QueryString["PassingValue"].ToString();

    2) Using Session

    An Easy solution is to use Session and it will be like this

    Your PageA.aspx

               //Set the value of Textbox to session
                Session["Data"] = "11/10/2014";
    //Perform your Redirect Response.Redirect("YourPageB.aspx");

    YourPageB.aspx(Receiver Page)

    You can read values from session like given below

                if (!String.IsNullOrEmpty(Session["Data"].ToString()))
                {
    
                    //Read values from session
                    string valueA = Session["Data"].ToString();
    
                }

     



    I ended up just using the UrlString and put it on the format dd-MM-yyyy and it worked nicely but I might start using Session - Presumably it hides the string?

    Monday, November 10, 2014 2:06 AM