Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir,

When I Clicking on Submit Button of Default.aspx page , Page is refreshing even i want to perform insert the Data into Database , "I checked always call get method after submit" . Please give the solution if any Idea You have guyz..
Posted

Before I answer your question, It would be interesting for you to know that ASP.NET is a server side language. It means that whatever operations happen in ASP.Net they are processed on the server. For this process to complete your browser sends the HTTP request to the server, the server then processes the request and sends the response back to the browser, browser then renders the page to you. Because of this activity your page seems to refresh.

You can avoid this by using AJAX. AJAX allows you to have partial postback. Now coming back to your question, you will have to use the UpdatePanel control of the AJAX control toolkit.

Refer these links to get started :
1. http://ajax.net-tutorials.com/controls/updatepanel-control/[^]
2. http://msdn.microsoft.com/en-us/library/bb386454.aspx[^]
3. http://www.asp.net/ajax/tutorials/understanding-asp-net-ajax-updatepanel-triggers[^]
4. Triggering AJAX UpdatePanel from a Button Click or DropDownList Selection Change in Code-Behind[^]

Hope this helps.
All the best.
 
Share this answer
 
Comments
the headless nick 5-Oct-11 7:25am    
very good answer. My vote 5.
Pravin Patil, Mumbai 5-Oct-11 7:28am    
Thanks buddy...
Pravin Patil, Mumbai 5-Oct-11 7:28am    
Thanks buddy..
BobJanova 5-Oct-11 11:55am    
Explanation and links for coding solutions, top answer. 5 for this
Pravin Patil, Mumbai 7-Oct-11 13:48pm    
Thanks Bob..
Try this one.

Place the Submit button in Update Pannel like

C#
<asp:ScriptManager ID="scriptmanager" runat="server" >

<asp:UpdatePanel ID="UpdatePanel" runat="server" >
 <contenttemplate>
          <asp:Button ID="btnsubmit" runat="server" Text="Submit" />
 </contenttemplate>
 
Share this answer
 
v6
If you dont want postback then use HTML control's.

Just try this might help

<asp:button ID="Button1" runat="server" text="Button" OnClientClick="return false;" />
 
Share this answer
 
Use ajax update panel.
place button in updatepanel
 
Share this answer
 
There are couple of way to implemement this.
1. Use ClientClick and pass all information through the AJAX.Post metthod

2. You can create the web serive and call those service by JSON

3. You can use UpdatePanel concept, this is the easiest way by by this way if you page has multiple control then you will face little performance issue as update panel will take time to render.
 
Share this answer
 
Hi,

Use Jquery.post() for posting data to server .
like
JavaScript
  $.post("index.aspx?action=add",{name1:value1,name2:value2},function(data){
  $("#divresult").html="Added successfully";
});


Step into Jquery.You'll enjoy the magic of jquery

All the Best
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900