javascript - Calling c# then js on same element -


I am using the following c # to change content from the server side:

  this.StatusPreview.InnerHtml = "server-side"; This.StatusPreview.Update ();  

I use the following js to change the content on the client side:

  document.getElementById ('StatusPreview '). WinnerHTML = "client side";  

If I perform the first js , then there is no problem. However, if I first run c # , then js , I get one,

  uncheck type error: property 'Internal HTML' can not be set to zero on  js  on line 

This element is affecting:

  & lt; Td id = "StatusPreview" runat = "server" & gt; & Lt; / TD & gt;  

When I execute c # , then it should be td to

  & lt; Span id was changed = "el_StatusPreview_container" & gt; Of the & lt; / Span & gt;  

Is there any way that will allow me to update c # without turning on my element << code> null ?

Thank you!

Since you want to update via server side and client side, you should change your method .

Leave the TD tag as a plain tag, and add a label as a child:

  & lt; Asp: Label ID = "StatusPreview" runat = "server" ClientIDMode = "static" />  

If Javascript updates it first, then it will discover this element. If the server side updates this, then ClientIdode is set with static, this ID will not change and since it is already a web control, it will not create a new element, so Javascript can still get it.


Comments