Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

page reload issue using ajax and jquery

$
0
0

We are loading a child page in the parent page parent.aspx as follows -

 $("#result").load("Child.aspx");

The Child.aspx consists of an asp:Button.

Problem -

OnClick of asp:Button is causing Child.aspx to be opened instead of being embedded in Parent.aspx as before the click event.

Expected -

Child.aspx should remain embedded in Parent.aspx onClick of the Asp:Button

What we tried: Added an UpdatePanel & ContentTemplate but the Child.aspx page is still getting refreshed.

[Snap1 ]Parent.aspx:-

snap1

onClick of Button in the Parent.aspx it loads the Child.aspx inside Parent.aspx as shown in Snap2

[Snap2 ]Child.aspx:-

snap2

[Snap3 ] onClick of AspPageButton in the Child.aspx, the Parent page dissapears and the Child.aspx page gets loaded as an individual page without being embedded within the Parent.aspx.

Expected: Child.aspx should remain embedded in Parent.aspx onClick/Submit of the Asp:Button

snap3

Code -

Parent.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Parent.aspx.cs" Inherits="NewLab.Parent" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/themes/redmond/jquery-ui.css" type="text/css" media="all" /><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script><script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/jquery-ui.min.js" type="text/javascript"></script><script src="/js/jquery.mousewheel.js" type="text/javascript"></script><script src="/js/jquery.colorbox.js"></script><title></title><script type="text/javascript">
         function openSection() {
             alert("openSection");$("#result").load("Child.aspx");
         }</script></head><body><form id="form1" runat="server"><asp:ScriptManager       
            runat="server"></asp:ScriptManager><h1>Parent Page</h1><asp:Button ID="lnkbtn" runat="server" Text="Button" OnClick="Button1_Click" Height="51px" Width="218px" /><asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><div id="result"></div></ContentTemplate></asp:UpdatePanel></form></body></html>

Child.aspx -
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Child.aspx.cs" Inherits="NewLab.Child" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title></title><script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/jquery-ui.min.js" type="text/javascript"></script><script type="text/javascript">
       function calljs() {

           alert("click");
           event.preventDefault();
       }</script></head><body><form id="form1" runat="server"><div style="background-color:blue; height:400px"><h1>CHILD PAGE LOADED!</h1><input type="button" value="htmlbutton" /><asp:Button ID="Button1" runat="server" Text="AspPageButton"/></div></form></body></html>


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>