By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,354 Members | 907 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,354 IT Pros & Developers. It's quick & easy.

Modify InnerHtml of HtmlControl with JavaScript?

P: n/a
Here is my current code:
------------
<script runat=Server>
void Page_Load(object sender, EventArgs e){
if (!IsPostBack){
myDiv.InnerHtml = "Original Content";
}
//On Postback, should equal "Original Content and New Content"
string strContent = myDiv.InnerHtml;
}
</script>
<script language=javascript>
function changeDiv(){
myDiv.innerHTML = myDiv.innerHTML + " and New Content";
document.forms(0).submit();
}
</script>
<form runat=Server>
<input type=button name=button value=Change onClick="changeDiv()">
</form>
<DIV id=myDiv runat=Server/>
------------

I need to be able to return the NEW InnerHtml value of "myDiv". The
original value is maintained in the ViewState, but does not reflect
the changes made with Javascript.

I don't want to use the client-side innerHTML property to retrieve the
data. Basically, I am trying to find a way to maintain state when the
changes to the control are client-side.

Any ideas? Thanks.
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
the browser only postbacks input , textarea, and selects, not the entire
html. the server code never see any changes made to div by client script.

-- bruce (sqlwork.com)

"Paul" <pa***************@yahoo.com> wrote in message
news:35**************************@posting.google.c om...
Here is my current code:
------------
<script runat=Server>
void Page_Load(object sender, EventArgs e){
if (!IsPostBack){
myDiv.InnerHtml = "Original Content";
}
//On Postback, should equal "Original Content and New Content"
string strContent = myDiv.InnerHtml;
}
</script>
<script language=javascript>
function changeDiv(){
myDiv.innerHTML = myDiv.innerHTML + " and New Content";
document.forms(0).submit();
}
</script>
<form runat=Server>
<input type=button name=button value=Change onClick="changeDiv()">
</form>
<DIV id=myDiv runat=Server/>
------------

I need to be able to return the NEW InnerHtml value of "myDiv". The
original value is maintained in the ViewState, but does not reflect
the changes made with Javascript.

I don't want to use the client-side innerHTML property to retrieve the
data. Basically, I am trying to find a way to maintain state when the
changes to the control are client-side.

Any ideas? Thanks.

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.