understanding client-side management

understanding client-side management

client-side management:-

—>   

client side management worldfree4uh

client side management

 

 view state:-

  • The ASP.NET framework uses the view state property to automatically save the values of the web page and each control on the web page prior to rendering the page.
  • each web page and controls on the page have the enableviewstate property.
  • by default, enableviewstate property will be set true.

—> advantages:-

  • simple for page level data.
  • encrypted
  • can be set at the control level
  • simple implementation

—> disadvantages:-

  • makes a page heavy as it consumes more memory.
  • device limitation

example with code:-

view state

by default it’s true but here we set false

code:-

Partial Class _Default
   Inherits System.Web.UI.Page

   Protected Sub Page1_Load(sender As Object, e As EventArgs) Handles Me.Load
      If Not Page.IsPostBack Then
         With DropDownList1.Items
            .Add("a")
            .Add("b")
            .Add("c")
            .Add("d")
         End With
      End If
   End Sub
End Class

run-time:-

data is fill

data is fill

click “button”, data will loss

cookies:-

  • cookies are handy when a particular user needs a specific piece of data, and it needs to be persisted for a variable period of time.
  • cookies are a small text file that browser creates and stores on the hard drive of your machine.
  • cookies can be either temporary or persistent.
  • usually, a cookie can have a maximum size of 4kb.
  • each cookie has the unique name.
Dim tmppoll As New HttpCookie("userpoll")

tmppoll.Values("given")=1
tmppoll.Expires = Datetime.Now.AddYears(1)

Response.Cookies.Add(tmppoll)

—> advantages:-

  • simplicity
  • no server resources are required
  • data persistence

—> disadvantages:-

  • size limitations
  • cookies can be disabled on user browsers
  • inappropriate for sensitive data

example:-

  • you might have noticed in the website like “remember me next” option. when the user checks this option, create a cookie with a value to identify the user.
  • when page loads, check for cookie existence. if it exists, read the cookie value.

query string:-

  • it is a information that is appended to the end of a page URL.
  • query strings are usually used to send information from one page to another page.they are passed along with URL of the request.
  • let’s assume that we have a data grid with a list of products, and a hyperlink in the grid that goes to a book deatil page, it would be an ideal use of the query string to include the book ID in the query string of the link to the book details page.

code:-

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Btn_Click(sender As Object, e As EventArgs) Handles Btn.Click
  'Response.Redirect("pagename" & value)
   Response.Redirect("form2.aspx" & txtname.Text)
End Sub
End Class

advantages:-

  • simple to implement
  • no server resources are required
  • widespread support

disadvantages:-

  • client browser limil on URL length
  • cross paging functionallity makes it redundant
  • limited capacity

hidden fields:-

  • it is used to store data on page level.
  • it has less number of proprties compare to other webserver control.

code:-

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Btn1_Click(sender As Object, e As EventArgs) Handles Btn1.Click
        HiddenField1.value = txtno1.Text
End Sub

Protected Sub Btn2_Click(sender As Object, e As EventArgs) Handles Btn2.Click
       txtno2.Text = HiddenField1.value
End Sub
End Class

advantages:-

  • no server resources are required
  • widespread support
  • simple implimentation
  • can store small amount of data so they take less size.

disadvantages:-

  • potential security risks
  • performance conideration
  • storage limitation













Reply