HtmlGenericControl not holding correct value....

  • Thread starter Thread starter Ralph Krausse
  • Start date Start date
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
 
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,
 
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)
 
Back
Top