Thursday, March 29, 2012
Performance related Question.....
can use the Label control to display my data here since I am using this edit
box as read only. Will there be any advantage of using label box instead of
text box in terms of memory usage or any other performance issue ? Please
advice.
CrisHi,
I don't think there are big differences between label and textbox, Both
of them are persistent accross requests.
The only difference is that the label iclude the text within <span> tags
while the textbox in the value property of the <input> tag. So there is
just a sligthly difference in the amount of byte sent to the browser.
Hope this helps
Stefano Mostarda MCP
Rome Italy
Cris Rock wrote:
> In my ASP.Net application I am using webcontrols.TextBox to display data. I
> can use the Label control to display my data here since I am using this edit
> box as read only. Will there be any advantage of using label box instead of
> text box in terms of memory usage or any other performance issue ? Please
> advice.
> Cris
>
Friday, March 16, 2012
Persistent ViewState
Imagine a form with several TextBox WebControls and two buttons "New" which
should clear the form and "Save". On reloading or leaving the page which
holds the form the TextBoxes should be cleared so I've disabled the
ViewStates of these TextBoxes by setting the EnableViewState property to
false.
The method which is bound to the OnClick event of the "New" button is
empty. When clicked a PostBack occurs which, theoretically, should be
sufficient to clear the TextBoxes because their state shouldn't be saved.
Unfortunately after the PostBack the data is still there! I've had a look
into the HTML source and found out that the value property of the TextBoxes
is set, so there's still a ViewState?! Even a ViewState.Clear() and/or
ClearChildViewState() within OnClick() doesn't work!
Disabling the ViewState for the whole page is no solution because the page
also contains a DataGrid and other controls which depend on the ViewState.
Please help!
Sincerely
Sven JacobsViewState is a different state persistance mechanism than the normal <form>
post data. ViewState is for data that is not part of the normal POST. The
text in a Label is saved in ViewState because a <span> doesn't post when
the form is submitted. The text in a TExtBox will be submitted, and thus
disabling viewstate has no effect on that.
-Brock
DevelopMentor
http://staff.develop.com/ballen
> Hello everybody!
> Imagine a form with several TextBox WebControls and two buttons "New"
> which should clear the form and "Save". On reloading or leaving the
> page which holds the form the TextBoxes should be cleared so I've
> disabled the ViewStates of these TextBoxes by setting the
> EnableViewState property to false.
> The method which is bound to the OnClick event of the "New" button is
> empty. When clicked a PostBack occurs which, theoretically, should be
> sufficient to clear the TextBoxes because their state shouldn't be
> saved. Unfortunately after the PostBack the data is still there! I've
> had a look into the HTML source and found out that the value property
> of the TextBoxes is set, so there's still a ViewState?! Even a
> ViewState.Clear() and/or ClearChildViewState() within OnClick()
> doesn't work!
> Disabling the ViewState for the whole page is no solution because the
> page also contains a DataGrid and other controls which depend on the
> ViewState.
> Please help!
>
> ViewState is a different state persistance mechanism than the normal <form>
> post data. ViewState is for data that is not part of the normal POST. The
> text in a Label is saved in ViewState because a <span> doesn't post when
> the form is submitted. The text in a TExtBox will be submitted, and thus
> disabling viewstate has no effect on that.
So what you saying is that the state persistance of a form is a feature of
HTTP / the browser? How to clear the form then, via JavaScript?
Thanks!
Sincerely
Sven Jacobs
> So what you saying is that the state persistance of a form is a feature of
> HTTP / the browser? How to clear the form then, via JavaScript?
Forget that! After reading this article
http://aspalliance.com/articleViewer.aspx?aId=135 I think I now what the
difference between ViewState and PostBack data is.
So what I have to do is not to import the PostBack data on a special
condition (=New button clicked).
Sincerely
Sven Jacobs
No, the form persistance is a feature of the ASP.NET runtime, in that it
matches the control id in the POST data and fills the associated value from
that. See
http://msdn.microsoft.com/library/d...br />
tate.asp
To clear the form, loop through the controls on the form, and check if the
control is a textbox, or certain type of control, then set the value to an
empty string, or index to -1 if a droplist etc. It really depends on what
type of control you are working with as there is no generic way of clearing
a form (AFAIK).
- Paul Glavich
ASP.NET MVP
ASPInsider (www.aspinsiders.com)
"Sven Jacobs" <sven.jacobs@.web.de> wrote in message
news:178f7ojd7o9bi.719p7zwjzasv$.dlg@.40tude.net...
<form>
The
> So what you saying is that the state persistance of a form is a feature of
> HTTP / the browser? How to clear the form then, via JavaScript?
> Thanks!
> --
> Sincerely
> Sven Jacobs
Persistent ViewState
Imagine a form with several TextBox WebControls and two buttons "New" which
should clear the form and "Save". On reloading or leaving the page which
holds the form the TextBoxes should be cleared so I've disabled the
ViewStates of these TextBoxes by setting the EnableViewState property to
false.
The method which is bound to the OnClick event of the "New" button is
empty. When clicked a PostBack occurs which, theoretically, should be
sufficient to clear the TextBoxes because their state shouldn't be saved.
Unfortunately after the PostBack the data is still there! I've had a look
into the HTML source and found out that the value property of the TextBoxes
is set, so there's still a ViewState?! Even a ViewState.Clear() and/or
ClearChildViewState() within OnClick() doesn't work!
Disabling the ViewState for the whole page is no solution because the page
also contains a DataGrid and other controls which depend on the ViewState.
Please help!
--
Sincerely
Sven JacobsViewState is a different state persistance mechanism than the normal <form>
post data. ViewState is for data that is not part of the normal POST. The
text in a Label is saved in ViewState because a <span> doesn't post when
the form is submitted. The text in a TExtBox will be submitted, and thus
disabling viewstate has no effect on that.
-Brock
DevelopMentor
http://staff.develop.com/ballen
> Hello everybody!
> Imagine a form with several TextBox WebControls and two buttons "New"
> which should clear the form and "Save". On reloading or leaving the
> page which holds the form the TextBoxes should be cleared so I've
> disabled the ViewStates of these TextBoxes by setting the
> EnableViewState property to false.
> The method which is bound to the OnClick event of the "New" button is
> empty. When clicked a PostBack occurs which, theoretically, should be
> sufficient to clear the TextBoxes because their state shouldn't be
> saved. Unfortunately after the PostBack the data is still there! I've
> had a look into the HTML source and found out that the value property
> of the TextBoxes is set, so there's still a ViewState?! Even a
> ViewState.Clear() and/or ClearChildViewState() within OnClick()
> doesn't work!
> Disabling the ViewState for the whole page is no solution because the
> page also contains a DataGrid and other controls which depend on the
> ViewState.
> Please help!
> ViewState is a different state persistance mechanism than the normal <form>
> post data. ViewState is for data that is not part of the normal POST. The
> text in a Label is saved in ViewState because a <span> doesn't post when
> the form is submitted. The text in a TExtBox will be submitted, and thus
> disabling viewstate has no effect on that.
So what you saying is that the state persistance of a form is a feature of
HTTP / the browser? How to clear the form then, via JavaScript?
Thanks!
--
Sincerely
Sven Jacobs
> So what you saying is that the state persistance of a form is a feature of
> HTTP / the browser? How to clear the form then, via JavaScript?
Forget that! After reading this article
http://aspalliance.com/articleViewer.aspx?aId=135 I think I now what the
difference between ViewState and PostBack data is.
So what I have to do is not to import the PostBack data on a special
condition (=New button clicked).
--
Sincerely
Sven Jacobs
No, the form persistance is a feature of the ASP.NET runtime, in that it
matches the control id in the POST data and fills the associated value from
that. See
http://msdn.microsoft.com/library/d...l/viewstate.asp
To clear the form, loop through the controls on the form, and check if the
control is a textbox, or certain type of control, then set the value to an
empty string, or index to -1 if a droplist etc. It really depends on what
type of control you are working with as there is no generic way of clearing
a form (AFAIK).
--
- Paul Glavich
ASP.NET MVP
ASPInsider (www.aspinsiders.com)
"Sven Jacobs" <sven.jacobs@.web.de> wrote in message
news:178f7ojd7o9bi.719p7zwjzasv$.dlg@.40tude.net...
> > ViewState is a different state persistance mechanism than the normal
<form>
> > post data. ViewState is for data that is not part of the normal POST.
The
> > text in a Label is saved in ViewState because a <span> doesn't post when
> > the form is submitted. The text in a TExtBox will be submitted, and thus
> > disabling viewstate has no effect on that.
> So what you saying is that the state persistance of a form is a feature of
> HTTP / the browser? How to clear the form then, via JavaScript?
> Thanks!
> --
> Sincerely
> Sven Jacobs