Retain changes made by javascript in custom controlhttp://forums.asp.net/t/1798099.aspx/1?Retain+changes+made+by+javascript+in+custom+controlWed, 02 May 2012 11:12:44 -040017980994956469http://forums.asp.net/p/1798099/4956469.aspx/1?Retain+changes+made+by+javascript+in+custom+controlRetain changes made by javascript in custom control <p>Hi,</p> <p>How to reatin the changes done in the asp.net custom server control by javascript? During the postback / page reloads, changes done by the javascript in custom control is not retained.</p> 2012-04-28T22:02:25-04:004956757http://forums.asp.net/p/1798099/4956757.aspx/1?Re+Retain+changes+made+by+javascript+in+custom+controlRe: Retain changes made by javascript in custom control <p>Every changes made on the client side needs to be put in input fields for the server to be able to get the updates on a postback. What kind of things are you changing in javascript?</p> 2012-04-29T11:11:22-04:004957067http://forums.asp.net/p/1798099/4957067.aspx/1?Re+Retain+changes+made+by+javascript+in+custom+controlRe: Retain changes made by javascript in custom control <p>Hi,</p> <p>Please refer the below link, i've added the complete code of my custom control &amp; test page.</p> <p>http://stackoverflow.com/questions/10367847/get-selected-text-asp-net-custom-server-control</p> <ul> <li>In that code javascript changes the achor tag inner text dynamically </li><li>Text property in that code sets &amp; gets the anchor tag inner text </li><li>During get Text, CreateChildControls() executes once again &amp; not retains the latest value </li></ul> 2012-04-29T16:39:17-04:004957263http://forums.asp.net/p/1798099/4957263.aspx/1?Re+Retain+changes+made+by+javascript+in+custom+controlRe: Retain changes made by javascript in custom control <p></p> <blockquote><span class="icon-blockquote"></span> <h4>anandhan</h4> <p></p> <p>Hi,</p> <p>How to reatin the changes done in the asp.net custom server control by javascript? During the postback / page reloads, changes done by the javascript in custom control is not retained.</p> <p></p> </blockquote> <p></p> <p>You can use a hidden field to store the value changed by javascriptand then at the beginning of Page_Loadyou can use Request.Form[&quot;hiddenfield&quot;] to fetch the value</p> <p>Reguards</p> 2012-04-30T01:22:51-04:004957883http://forums.asp.net/p/1798099/4957883.aspx/1?Re+Retain+changes+made+by+javascript+in+custom+controlRe: Retain changes made by javascript in custom control <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Decker Dong - MSFT</h4> <p></p> <p>You can use a hidden field to store the value changed by javascriptand then at the beginning of Page_Loadyou can use Request.Form[&quot;hiddenfield&quot;] to fetch the value</p> <p></p> </blockquote> <p></p> <p>Hi,</p> <p>I've created hidden field in custom control, the value is changing from client page, when postback occurs it is not retaining the latest value as the control is created once on postback.</p> 2012-04-30T09:46:25-04:004959241http://forums.asp.net/p/1798099/4959241.aspx/1?Re+Retain+changes+made+by+javascript+in+custom+controlRe: Retain changes made by javascript in custom control <p></p> <blockquote><span class="icon-blockquote"></span> <h4>anandhan</h4> I've created hidden field in custom control, the value is changing from client page, when postback occurs it is not retaining the latest value as the control is created once on postback.</blockquote> <p></p> <p>Where and how did you create it</p> 2012-05-01T05:28:30-04:004959258http://forums.asp.net/p/1798099/4959258.aspx/1?Re+Retain+changes+made+by+javascript+in+custom+controlRe: Retain changes made by javascript in custom control <p></p> <blockquote><span class="icon-blockquote"></span> <h4>anandhan</h4> <p></p> <p>Hi,</p> <p>How to reatin the changes done in the asp.net custom server control by javascript? During the postback / page reloads, changes done by the javascript in custom control is not retained.</p> <p></p> </blockquote> <p></p> <p>Save all changes in input fied like text box and other text box make sure that all are server side control mean runat =&quot;server&quot; is set. and fill all this field by javascripts so that will be retain there view by viewstate.</p> 2012-05-01T05:44:50-04:004960335http://forums.asp.net/p/1798099/4960335.aspx/1?Re+Retain+changes+made+by+javascript+in+custom+controlRe: Retain changes made by javascript in custom control <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Decker Dong - MSFT</h4> <p></p> <p>Where and how did you create it</p> <p></p> </blockquote> <p></p> <p>I've created the hidden field in CreateChildControls();</p> 2012-05-01T17:14:20-04:004960659http://forums.asp.net/p/1798099/4960659.aspx/1?Re+Retain+changes+made+by+javascript+in+custom+controlRe: Retain changes made by javascript in custom control <p></p> <blockquote><span class="icon-blockquote"></span> <h4>anandhan</h4> I've created the hidden field in CreateChildControls();</blockquote> <p></p> <p>And please make sure that OnInit or OnLoad eventplease use something like Context.Request.Form[hiddenfield.UniqueUrl] to accept the value</p> 2012-05-02T00:58:41-04:004961655http://forums.asp.net/p/1798099/4961655.aspx/1?Re+Retain+changes+made+by+javascript+in+custom+controlRe: Retain changes made by javascript in custom control <p><span style="text-decoration:underline"><strong>Registered Hidden Field in OnPreRender()</strong></span></p> <p>Page.ClientScript.RegisterHiddenField(&quot;sTextHiddenField&quot;, (string)ViewState[&quot;Text&quot;]);</p> <p><span style="text-decoration:underline"><strong>Selected Text Property</strong></span></p> <p>Used Context.Request.Form[hiddenfield.UniqueUrl] in property to get the changes made by javascript</p> <pre class="prettyprint">public string Text { get { if(this.Page.IsPostBack) ViewState[&quot;Text&quot;] = this.Context.Request.Form[&quot;sTextHiddenField&quot;].ToString(); return ViewState[&quot;Text&quot;].ToString(); } set { ViewState[&quot;Text&quot;] = value; } }</pre> 2012-05-02T11:12:44-04:00