1 / 4
2 / 4
3 / 4
4 / 4

Tuesday, 21 January 2020

Query string,Client Side Sate Management. Part-3

  1.              This is a Client-side State Management Technology, i.e. the data we want to manage; it is        going to store in the client machine.
  2.                In this technique, we can maintain the value/data on the same page or another page through the URL.
      3.       Here we have to concatenate the required Data with the Page URL  with the help of  "?" mark symbol.
                 www.mypalmbook.com?id=1001
      4.       If we want to carry more than one data in the query string then we have to concatenate the next data with “&” (ampersand) symbol.
                www.mypalmbook.com?id=1001 & name=Biswarekha


Example:-

>>In QuerystringDemo.aspx

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body style="background-color:azure">
    <form id="form1" runat="server">
        <div>
            Id: <asp:Label ID="lblId" runat="server" Text="1002"></asp:Label>
            <br />
            Name: <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
            <br />
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Next" />
            <asp:HyperLink ID="hlSend" runat="server" NavigateUrl="~/QuerystringRedirectionPage.aspx?id=1001&name=Rupa" Text="Send"/>
        </div>
    </form>
</body>
</html>



>>In QuerystringDemo.aspx.cs

using System;
namespace MyPalmBookWeb
{
    public partial class QuerystringDemo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            //Response.Redirect("QuerystringRedirectionPage.aspx?id="+lblId.Text+"&name="+txtName.Text);
            Server.Transfer("QuerystringRedirectionPage.aspx?id=" + lblId.Text + "&name=" + txtName.Text);
        }
    }
}


>>In QuerystringRedirectionPage.aspx

-- nothing to design

>>In QuerystringRedirectionPage.aspx.cs


using System;

namespace MyPalmBookWeb

{

    public partial class QuerystringRedirectionPage : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            Response.Write("Hello, " + Request.QueryString["name"]+" Welcome to our Company.<br/>");

            Response.Write("you are assigned with Id: "+Request.QueryString["id"]);
        }
    }
}



Draw Backs:-

  1.  This is not a secure method to transfer the Sensitive data, because data will be visible to the user on the address bar of the browser.
  2.   Querystring cannot carry more volume of data. 

Watch the video for Live Examples
Coming Soon

No comments:

Post a Comment

If you have any doubts please let me know