Home > DeveloperSection > Forums > __doPostBack clears all text fields
lois waisbrooker
lois waisbrooker

Total Post:70

Points:494
Posted on    November-20-2014 10:08 PM

 ASP.Net ASP.Net  JQuery 
Ratings:


 1 Reply(s)
 657  View(s)
Rate this:

I want to call an ASP.NET code behind method from JQuery and I use it by calling another hidden button OnClick attribute.

As you see I have to use __doPostBack function which clears all my form inputs after code behind code is done.

Is there a way to prevent emptying my inputs?

Thanx in advance

ASPX:

<asp:Button runat="server" ClientIDMode="Static" UniqueID="SubmitBTN" ID="SubmitBTN" OnClick="Submit_Click" Text="Submit" CssClass="DontShow" />

button type="button" runat="server" onclick="submitfunc()" class="submit">Submit</button>

JQuery:

function submitfunc() {

     __doPostBack('<%= SubmitBTN.UniqueID %>', '');

}



Elena Glibart
Elena Glibart

Total Post:35

Points:128
Posted on    November-21-2014 12:14 AM

try like this:

wrap your contents with Update Panels as Shown below or You can make Ajax Calls Using Jquery

 <asp:ScriptManager runat="server" ID="scriptManger1" />

    <asp:UpdatePanel runat="server">

        <ContentTemplate>

<asp:Button runat="server" ClientIDMode="Static" UniqueID="SubmitBTN" ID="SubmitBTN" OnClick="Submit_Click" Text="Submit" CssClass="DontShow" />

<button type="button" runat="server" onclick="submitfunc()" class="submit">Submit</button>

  </ContentTemplate>

    </asp:UpdatePanel>


Don't want to miss updates? Please click the below button!

Follow MindStick