Hi Scott,
I'm getting the id across now, but i still can not find the control. I'm
running in 2k8 debug if that some how causes issues. I appreciate your
help.
just to make sure i'm doing this correctly:
page on in sub directory with master:
public partial class Admin_x : System.Web.UI.Page
{
public String ButtonClientID
{
get
{
return btnSendAlert.ClientID;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
page 2 header with reference:
<%@ Page Language="C#" MasterPageFile="~/Admin/adminMasterPage.master"
AutoEventWireup="true" CodeFile="y.aspx.cs" Inherits="Admin_y"
Title="Untitled Page" %>
<%@ PreviousPageType VirtualPath="~/Admin/x.aspx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
</asp:Content>
page 2 code behind:
public partial class Admin_y : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (PreviousPage != null)
{
Response.Write(PreviousPage.ButtonClientID.ToString());
Response.Write("<BR />");
Button btn =
(Button)PreviousPage.FindControl(PreviousPage.ButtonClientID);
if (btn == null)
Response.Write("NG");
else
Response.Write("OK");
}
}
}
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)
kes
Scott M. said:
The problem is that when you have content in a contentpage, the ID's of
the
rendered controls are not the same as what you named them. You should
use
the ClientID property to identify it. But, since the control is from the
previous page, you'll need to pass the clientID to the new page, which
you
can do via a crosspagepostback property as in:
[source page]
public String ButtonClientID
{
get
{
return btnSendAlert.ClientID;
}
}
[.aspx destination page]
Make sure that a reference to the previous page is declared at the top
like
this:
<%@ PreviousPageType VirtualPath="~/SourcePage.aspx" %>
[.aspx.cs destination page]
if (PreviousPage != null)
{
Button btn =
(Button)PreviousPage.FindControl(PreviousPage.ButtonClientID);
Response.Write(btn.Text);
}
Good luck!
-Scott
message
yes
--
(i''ll be asking a lot of these, but I find C# totally way cooler than
vb
and there''s no go''n back!!!)
thanks (as always)
kes
:
Are you using MasterPages here?
message
I the page knows there was a cross post back. but i can not find the
control.
(asp.net 3.5)
calling page has a master
calling control:
<asp:Button ID="btnSendAlert" runat="server" Text="Go"
onclick="btnSendAlert_Click"
PostBackUrl="ItemUpLoadAdmin.aspx"
CommandArgument="5" />
receiving page
if (PreviousPage != null)
{
Button btn =
(Button)PreviousPage.FindControl("btnSendAlert");
Response.Write(btn.Text); <--- errors here with null
reference
}
--
(i''ll be asking a lot of these, but I find C# totally way cooler
than
vb
and there''s no go''n back!!!)
thanks (as always)
kes