HtmlGenericControl not holding correct value....

R

Ralph Krausse

I am updating a span tag with the title of my expanded node (a 3rd
party control).text that I wish to get later in my codebehind file.

my tag in my html
<span class="hint" runat="server" id="ExpandedNode">Select</span>

my javascript code
function nodeExpand(node)
{
document.getElementById('ExpandedNode').innerText = node.Text;
return true;
}

then in my codebehind (cs) file....


HtmlGenericControl objExpandedNode =
(HtmlGenericControl)Application["ExpandedNode"];
string strBuffer = (string)objExpandedNode.InnerText;

strBuffer's value is 'Select' not the text of node.text (but I did see
it change in the browser BEFORE it hit my break point). I also have
tried string strBuffer = (string)objExpandedNode.InnerHTML

Anyone. I need to get this text in my codebehind file and the
javascript changes it....



thanks

Ralph Krausse
www.consiliumsoft.com
Use the START button? Then you need CSFastRunII...
A new kind of application launcher integrated in the taskbar!
ScreenShot - http://www.consiliumsoft.com/ScreenShot.jpg
 
J

Joerg Jooss

Ralph said:
I am updating a span tag with the title of my expanded node (a 3rd
party control).text that I wish to get later in my codebehind file.

my tag in my html
<span class="hint" runat="server" id="ExpandedNode">Select</span>

my javascript code
function nodeExpand(node)
{
document.getElementById('ExpandedNode').innerText = node.Text;
return true;
}

then in my codebehind (cs) file....


HtmlGenericControl objExpandedNode =
(HtmlGenericControl)Application["ExpandedNode"];
string strBuffer = (string)objExpandedNode.InnerText;

strBuffer's value is 'Select' not the text of node.text (but I did see
it change in the browser BEFORE it hit my break point). I also have
tried string strBuffer = (string)objExpandedNode.InnerHTML

Anyone. I need to get this text in my codebehind file and the
javascript changes it....

It's not that easy. The HtmlGenericControl gets its text from the page's
ViewState, which of course does not reflect the changes done by the
JavaScript function. You need to communicate this client-side update, e.g.
by putting the new text in a hidden field.

Cheers,
 
B

bruce barker

this approach will not work. the browser only post back form controls
(buttons, input, textarea and select) values. changing the innerText of a
span on the client will not chage the value on the server.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top