dynamic objects

  • Thread starter Thread starter Jose Marcenaro
  • Start date Start date
J

Jose Marcenaro

Just do this (C# syntax)

ViewState["RowsSent"] = n;

and then

n = ViewState["RowsSent"];

Regards
Jose Marcenaro
 
The question is quiet difficult to explain -
I need to give the users ability to append to a table rows, that means I
have to reconstruct it every time there's a PostBack i nOnInit event. The
question how can I remember how many rows were sent to client before the
last submit? I've read a little bit about viewstate and tried to make a
hidden label (with runat=server property), but couldn't retrieve its' value
fro ViewState. Please help.
Thank you a lot.
 
Thanks a lot! it worked :)
Another small question - If I understand correctly, ViewState saves values
of all objects that have runat=server. How can I isolate a certain object
(let's say an asp:TextBox) that I have on my ASPX page in order to receive
it's value from ViewState? Can I or can't?

And also may be an object/value added/removed/edited to ViewState from
JavaScript??
This one would solve a great problem I have with my project. Thank in
advance.

--
With the best wishes,
Shaul Feldman

Jose Marcenaro said:
Just do this (C# syntax)

ViewState["RowsSent"] = n;

and then

n = ViewState["RowsSent"];

Regards
Jose Marcenaro

Shaul Feldman said:
The question is quiet difficult to explain -
I need to give the users ability to append to a table rows, that means I
have to reconstruct it every time there's a PostBack i nOnInit event. The
question how can I remember how many rows were sent to client before the
last submit? I've read a little bit about viewstate and tried to make a
hidden label (with runat=server property), but couldn't retrieve its' value
fro ViewState. Please help.
Thank you a lot.
 
Shaul Feldman said:
Thanks a lot! it worked :)
Another small question - If I understand correctly, ViewState saves values
of all objects that have runat=server. How can I isolate a certain object
(let's say an asp:TextBox) that I have on my ASPX page in order to receive
it's value from ViewState? Can I or can't?

You don't have to worry about reading the viewstate of the object. If it has
viewstate, then it will internally use it to pull from it all the control
properties, and you just access TextBox1.Text, TextBox1.Tooltip, etc (you
may do this on PageLoad when IsPostBack=true)
And also may be an object/value added/removed/edited to ViewState from
JavaScript??

Nope. It's an internal proprietary format.
The way to send info from js to your server aspx page is filling an actual
control (i.e. Textbox) or a hidden HTML field placed inside the <asp:Form>
You may access its value either with the .Text property, or with
Request["fieldName"].Value

Hope this help, regards
Jose Marcenaro
 
Back
Top