Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Accessing Composite Control Viewstate stored properties fromclientside Javascript

Reply
Thread Tools

Accessing Composite Control Viewstate stored properties fromclientside Javascript

 
 
Andy
Guest
Posts: n/a
 
      04-08-2010
I've created a composite control called GRIDLOOKUP that contains an
ASP:LINKBUTTON and ASP:IMAGEBUTTON. I've also added TEXT and KEY
properties to GRIDLOOKUP which store their values in GRIDLOOKUP's
viewstate.

GRIDLOOKUP copies its TEXT property to the LINKBUTTON's TEXT property,
so that the current value of GRIDLOOKUP is displayed in the
LINKBUTTON. When GRIDLOOKUP makes its round trip between the client
and server, both TEXT and KEY properties are persisted properly.

I've placed GRIDLOOKUP in a DataGrid Template on a webpage. When the
webpage runs, the datagrid renders GRIDLOOKUP correctly, and the
values for the column GRIDLOOKUP is attached to appear correctly in
the LINKBUTTON.

When the user clicks the IMAGEBUTTON, I want to change the values of
TEXT and KEY for the corresponding GRIDLOOKUP the user selected
through javascript on the clientside.. Unfortunately, GRIDLOOKUP
renders only the LINKBUTTON and IMAGEBUTTON. There is no GRIDLOOKUP
control visible in the HTML of the page. Yet, in the codebehind of
the webpage during the postback, I can access the TEXT and KEY
properties of GRIDLOOKUP.

Should I be accessing TEXT from the LINKBUTTON instead during the
postback to the webpage and transfering its value to the GRIDLOOKUP
composite control at that point?

Or is there a way to do this from the GRIDLOOKUP codebehind?
 
Reply With Quote
 
 
 
 
Andy
Guest
Posts: n/a
 
      04-09-2010
After running a viewstate parser, changing the values of various
controls on a webpage, and inspecting the viewstate on both the client
and the server, I've determined that viewstate is never manipulated,
saved, or accessed on the client from clientside script code, internet
explorer, or anything else in a client tier.

Viewstate is solely a mechanisim for persisting property values set in
server-side codebehinds between consecutive invocations of that
codebehind. It does not transfer any new values keyed by a user on a
client to the server-side codebehind. It only provides functionality
that is similar to what asp.session variables or page.caches provide
to persist data in server-side code, except that the client is used to
store the persisted data rather than any server resources.

The only way to persist values keyed by a user in a clientside control
via viewstate is to have the control do a postback to the codebehind
where its value is then read from the Request.Form NameValueCollection
and manually copied to a viewstate variable. The contents of that
variable will then be available again in subsequent invocations of the
codebehind only.

ASP.NET has another mechanism to automatically pre-populate
ASP:Controls from a previous post, however, it does this from the
form's posted data rather than from viewstate.
 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      04-09-2010
> Unfortunately, GRIDLOOKUP
> renders only the LINKBUTTON and IMAGEBUTTON. There is no GRIDLOOKUP
> control visible in the HTML of the page.


Ultimately ASP.NET renders an HTML page.

> Yet, in the codebehind of
> the webpage during the postback, I can access the TEXT and KEY
> properties of GRIDLOOKUP.


The controls you are suign server side are just a programming model that
allows to easily generate HTML markup code consumed by browser so this
programming model is only available server side.

> Should I be accessing TEXT from the LINKBUTTON instead during the
> postback to the webpage and transfering its value to the GRIDLOOKUP
> composite control at that point?


Not sure to really understand what you are trying to do but :
- you'll know which control triggered the postback. As text and value are
persisted in view state you'll be able then to know which values are
associated with the clicked control.

If you want to get this client side rather than server side, this is done by
generating the appropriate client side code that will use the current value
of text and key to create the event handler (the viewstate is just an
internal "value bag" that you'll never access client side this way, you have
to explictely inject client side the data you need).

--
Patrice



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Composite Control and accessing complex properties of child controls - C# VS2005 Paul Yanzick ASP .Net Building Controls 4 01-09-2006 01:11 AM
Losing Composite Control property that another Composite Control ... Chad ASP .Net Building Controls 0 02-01-2005 09:01 PM
Composite Control - Viewstate management for complex properties Matt T. ASP .Net Building Controls 1 09-11-2004 11:40 AM
Possible to create a composite control that has a child control that is a validator that validates the composite control itself? Jonathan Eric Miller ASP .Net Building Controls 2 07-22-2004 10:58 PM
ViewState of the Composite Control composed of custom control whoisnidhee ASP .Net Web Controls 2 07-16-2004 08:05 AM



Advertisments