473,406 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

asp.net using jQuery Ajax - Parent page dissapears onClick of a Button in Child page

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.

Parent.aspx:-
onClick of Button will load another page i.e Child.aspx page within the <div id="result"></div> of the Parent page itself using

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

The Child.aspx page gets loaded inside the Parent.aspx page. The Child.aspx page consists of an Asp.net button named "ChildPageButton". onClick of ChildPageButton reloads the page and causes the Parent.aspx page to dissapear.

The Child.aspx page appears as an individual page, rather it should remain embedded inside the Parent.aspx

Parent.aspx -
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Parent.aspx.cs" Inherits="NewLab.Parent" %>
  2.  
  3. <!DOCTYPE html>
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head runat="server">
  7.     <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/themes/redmond/jquery-ui.css" type="text/css" media="all" />
  8.     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
  9.     <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/jquery-ui.min.js" type="text/javascript"></script>
  10.     <script src="/js/jquery.mousewheel.js" type="text/javascript"></script>
  11.     <script src="/js/jquery.colorbox.js"></script>
  12.     <title></title>
  13.  
  14.      <script type="text/javascript">
  15.          function openSection() {
  16.              alert("openSection");
  17.              $("#result").load("Child.aspx");
  18.          }
  19.     </script>
  20.  
  21. </head>
  22. <body>
  23.     <form id="form1" runat="server">
  24.          <asp:ScriptManager       
  25.             runat="server">
  26.         </asp:ScriptManager>
  27.         <h1>Parent Page</h1>
  28.      <asp:Button ID="lnkbtn" runat="server" Text="Button" OnClick="Button1_Click" Height="51px" Width="218px" />
  29.        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
  30.                      <ContentTemplate>
  31.         <div id="result"></div>
  32.                 </ContentTemplate>
  33.             </asp:UpdatePanel>
  34.     </form>
  35. </body>
  36. </html>
  37.  
  38.  
  39.  
  40. Parent.aspx.cs - 
  41.  
  42. using System;
  43. using System.Collections.Generic;
  44. using System.Linq;
  45. using System.Web;
  46. using System.Web.UI;
  47. using System.Web.UI.WebControls;
  48.  
  49. namespace NewLab
  50. {
  51.     public partial class Parent : System.Web.UI.Page
  52.     {
  53.         protected void Page_Load(object sender, EventArgs e)
  54.         {
  55.  
  56.         }
  57.  
  58.         protected void Button1_Click(object sender, EventArgs e)
  59.         {
  60.             if (!ClientScript.IsStartupScriptRegistered("openSection"))
  61.             {
  62.                 Page.ClientScript.RegisterStartupScript(this.GetType(),
  63.                     "openSection", "openSection();", true);
  64.             }
  65.         }
  66.     }
  67. }
  68.  
  69.  
  70. Child.aspx - 
  71.  
  72. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Child.aspx.cs" Inherits="NewLab.Child" %>
  73.  
  74. <!DOCTYPE html>
  75.  
  76. <html xmlns="http://www.w3.org/1999/xhtml">
  77. <head runat="server">
  78.     <title></title>
  79.  
  80.     <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/jquery-ui.min.js" type="text/javascript"></script>
  81.    <script type="text/javascript">
  82.        function calljs() {
  83.  
  84.            alert("click");
  85.            event.preventDefault();
  86.        }
  87.    </script>
  88. </head>
  89. <body>
  90.     <form id="form1" runat="server">
  91.    <div style="background-color:blue; height:400px">
  92.  
  93.             <h1>CHILD PAGE LOADED!</h1>
  94.         <input type="button" value="htmlbutton" />
  95.        <asp:UpdatePanel>
  96.            <ContentTemplate>
  97.             <asp:Button ID="Button1" runat="server" Text="AspPageButton"/>
  98.             </ContentTemplate>            
  99.            </asp:UpdatePanel>
  100.         </div>
  101.     </form>
  102. </body>
  103. </html>
  104.  
  105.  
  106. Child.aspx.cs - 
  107.  
  108. using System;
  109. using System.Collections.Generic;
  110. using System.Linq;
  111. using System.Web;
  112. using System.Web.UI;
  113. using System.Web.UI.WebControls;
  114.  
  115. namespace NewLab
  116. {
  117.     public partial class Child : System.Web.UI.Page
  118.     {
  119.         protected void Page_Load(object sender, EventArgs e)
  120.         {
  121.  
  122.         }
  123.     }
  124. }













Thanx in advance
Jun 28 '14 #1
0 1173

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: ratnakarp | last post by:
Hi, I have a.aspx page, which contains few buttons. On clicking one of the button, opens b.aspx. I have a button in b.aspx, on clicking, it closes the b.aspx and refreshes a.aspx. I'm able to...
2
by: Luigi | last post by:
I'm pretty new in asp.net 2.0 and i'm experiencing this problem: in the master page code i've included some general initialization code common to all content pages, but when i start debugging this...
3
by: querry | last post by:
Hi there, I have a problem. I am devloping a C# ASP.NET User Control (a .ascx file). I want to display a table on the user control. This table is generated on the fly. First the...
5
by: cheergurl | last post by:
i have a problem to display the data inserted at parent page.After i click a button submit at child page,the data that was inserted before are lost...can anybody give a solution to me how to remain...
1
by: cheergurl | last post by:
i have two text box inside parent page (one for user name, another one for department name) and one button that will open child page. i will choose department name at child page.The value will pass...
0
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I am using a popup control extender (ajax control) and have placed a .net button on the panel that is displayed when the hyperlink is selected that is the target control of the popup extender. ...
4
by: Buddha | last post by:
Hello, I posted this on two forums, without too much help .. and I am kinda stuck in this. I need to refresh the parent page from the second child window which is opened by the first child and...
29
Frinavale
by: Frinavale | last post by:
I have 2 FireFox (version 2) browser windows opened. One is the child of the other. When the user is finished with the child window, a method in the parent window is called to refresh a...
1
ilya Kraft
by: ilya Kraft | last post by:
I guess it is sort of simple question, but I'm not the AJAX guy, tried it, but I still don't understand it ))) Here is the situation: 1) I get one random url from database $sql = ("SELECT...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.