Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get the html code modified client side that was generated from the server side?
    primarykey
    data
    text
    <p>I created a list with jquery sortable + C#, that the user (client) can order:</p> <pre><code>protected override void OnInit(EventArgs e) { base.OnInit(e); HtmlGenericControl ul = new HtmlGenericControl("ul"); ul.ID = "ID"; ul.ClientIdMode = Static; HtmlGenericControl li_1 = new HtmlGenericControl("li"); li_1.ID = "segment"; li_1.InnerText = "server 1"; li_1.ClientIdMode = Static; HtmlGenericControl li_2 = new HtmlGenericControl("li"); li_2.ID = "page"; li_2.InnerText = "server 1"; li_2.ClientIdMode = Static; ul.Controls.Add(li_1); ul.Controls.Add(li_2); static.Controls.Add(ul); } </code></pre> <p>Server Generate:</p> <pre><code>&lt;div id="static" runat="server"&gt; &lt;ul id="ID"&gt; &lt;li id="segment"&gt;server 1&lt;/li&gt; &lt;li id="page"&gt;server 2&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>Client Generate (modified):</p> <pre><code>&lt;div id="static" runat="server"&gt; &lt;ul id="ID"&gt; &lt;li id="page"&gt;client 1&lt;/li&gt; &lt;li id="segment"&gt;client 2&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>Event Save:</p> <pre><code>protected void btnSave_Click(object sender, EventArgs e) { HtmlGenericControl ul = Libreria.Global.FindControlRecursivo(this, "ID") as HtmlGenericControl; foreach(HtmlGenericControl li in ul.Controls.OfType&lt;HtmlGenericControl&gt;()) { // Always get html generated by server, first "segment" element and after "page" element } } </code></pre> <p>If every time I generate dynamic code on every postback I always get the code that the server generates, if valid then the lists are empty postback. =(</p> <p>How do I get the html code modified client side that was generated from the server side?</p> <p><strong>Update:</strong> other option is using <strong>WebMethods</strong> with javascript send the html:</p> <pre><code>document.getElementById("ID").innerHTML; </code></pre> <p>I Can´t process the elements is a simple string</p> <pre><code>HtmlGenericControl ul = new HtmlGenericControl(); ul.InnerHtml = stringHtml; foreach(HtmlGenericControl li in ul.Controls.OfType&lt;HtmlGenericControl&gt;()) { // any element } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload