Modify InnerHtml of HtmlControl with JavaScript?

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Modify InnerHtml of HtmlControl with JavaScript?

    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.
    Paul Guest

  2. Similar Questions and Discussions

    1. FP8 IE BUG - innerHtml
      Hi everybody. When i make a loadMovie() and load a swf into the master swf a funny thing appends... if you load the master swf into some div via...
    2. Modify the javascript from CFFORM?
      Hi, Is there a way to modify the javascript created by CFFORM. It seems to be created at run-time. I am trying to make one field required if...
    3. innerhtml problems in IE5/Mac
      IE5/Mac users are encountering a problem with a web page that IE/PC users are not encountering. The problem is....I have a form which has an...
    4. Why can't I make a custom control from System.Web.UI.HtmlControls.HtmlControl?
      Scenario: I make a custom control, inheriting from System.Web.UI.HtmlControls.HtmlControl as follows: public class MyControl :...
    5. Setting the innerHTML on a <span>
      Sorry, That was a typo. It should read. I have a RequiredFieldValidator This gets rendered out as a <span> I want to set the innerHTML.
  3. #2

    Default 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_nospamplease@yahoo.com> wrote in message
    news:354f245e.0308040715.6518e05e@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.

    bruce barker Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139