JQuery AJAX and ASP.NET

I have this little problem ... I have an asp.net website. I have a menu, everything is done with html and css. Therefore, when I click on the house, ajax loads other content into the specified div element. It works 100%.

In the content that was loaded into the div element, I have a button. ASP.NET Button

When I click the button, it gives me "Resource cannot be found." error.

Something must be missing me. If you do not understand, heres ajax:

//Load the Home page on click. $(document).ready(function () { $('.home').click(function () { $("#content").load("html/home/home.aspx"); }); }); 

Now the aspx page that has been loaded into the contents of the div displays the btnAdd button:

 <asp:Panel ID="pnlAddNewBlog" runat="server"> <asp:TextBox ID="txtAddNewBlog" runat="server" TextMode="MultiLine"></asp:TextBox> <br /> <asp:Button ID="btnAdd" runat="server" Text="Add" /> </asp:Panel> 

When I click on this button, an error appears.

I want to achieve: when the user clicks the button, the text in txtAddNewBlog is added to the database. Now I can achieve the use of C # ... but not if this error is in my way. Any ideas?

+6
source share
1 answer

The problem is creating the form . When you make this request, ASP.NET will build a form whose purpose is home.aspx and not the full path to it. But you dump this form to an HTML page at a different level.

When you make a message in the form, it tries to send a message to home.aspx as to where the browser considers it to be on two levels and it does not find it.

I don't know if there is a good way to do this - ASP.NET is not designed to handle this kind of thing. You can use IFRAME. You can wrap the contents of home.aspx in a user control and leave the ASP.NET form on an external page. Or you can manipulate the purpose of the form to publish it in the right place. But I do not think that would be very fun.

+1
source

All Articles