Modify InnerHtml of HtmlControl with JavaScript?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul

    #1

    Modify InnerHtml of HtmlControl with JavaScript?

    Here is my current code:
    ------------
    <script runat=Server>
    void Page_Load(objec t 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=javasc ript>
    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="change Div()">
    </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.
  • bruce barker

    #2
    Re: Modify InnerHtml of HtmlControl with JavaScript?

    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" <paul_nospample ase@yahoo.com> wrote in message
    news:354f245e.0 308040715.6518e 05e@posting.goo gle.com...[color=blue]
    > Here is my current code:
    > ------------
    > <script runat=Server>
    > void Page_Load(objec t 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=javasc ript>
    > 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="change Div()">
    > </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.[/color]


    Comment

    Working...