mikha
asked on
how to call a function in aspx page , from a user control (ascx) page in asp.net application.
I have an asp.net web application, with master pages , aspx pages and also user control (ascx ) pages. sample code below
I have a function in menu.ascx , user control page, which needs to fire a function in default.aspx page.
is there a way to do this ?
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.c s" Inherits="masterpage.Site1 " %>
<%@Register Src=~/menu.ascx” TagName=”menu” TagPrefix=”uc1” %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<div id="navigaion">
<uc1:menu ID=”menuControl” runat=”server” />
</div>
<div id="maincontent">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder>
</div>
</body>
</html>
I have a function in menu.ascx , user control page, which needs to fire a function in default.aspx page.
is there a way to do this ?
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.c
<%@Register Src=~/menu.ascx” TagName=”menu” TagPrefix=”uc1” %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<div id="navigaion">
<uc1:menu ID=”menuControl” runat=”server” />
</div>
<div id="maincontent">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder>
</div>
</body>
</html>
ASKER
@Kyle- Thanks for your comment. I am new to events and delegates in .NET. I will research on this as well.
but based on your comment.
1. can I fire the event from the ascx page (not from cs code) . can i define my own custom event , similar to say , onbuttonclick = callsomemethod in the ascx page?
2. my use case is , I have a master page , with both ascx and aspx page that loads with in the master page, and I need to pass an int parameter from ascx page to aspx page.
how can i pass an int parameter ?
if you have sample of master page, aspx and ascx page , working together , will give me a better picture. right now, i'm not entirely sure on how this events are fired and tied together.
but based on your comment.
1. can I fire the event from the ascx page (not from cs code) . can i define my own custom event , similar to say , onbuttonclick = callsomemethod in the ascx page?
2. my use case is , I have a master page , with both ascx and aspx page that loads with in the master page, and I need to pass an int parameter from ascx page to aspx page.
how can i pass an int parameter ?
if you have sample of master page, aspx and ascx page , working together , will give me a better picture. right now, i'm not entirely sure on how this events are fired and tied together.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASCX:
Open in new window
ASPX:
Open in new window