470,855 Members | 1,158 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,855 developers. It's quick & easy.

Unable to pass values from aspx to ascx UserControl

This one has me stumped and I've spent countless hours trying to find a
solution. I have a UserControl being called from my main .aspx page.

main-page.aspx:
<%@ Register TagPrefix="my" TagName="control" Src="~/tmpcontrol.ascx"
%>
....
<my:control id="my-control1" runat="server" SomeVal="TestString" />
....

tmpcontrol.ascx:
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="tmpcontrols.ascx.cs" Inherits="tmpcontrols" %>
......

tmpcontrols.ascx.cs:
public partial class tmpcontrol : System.Web.UI.UserControl
{
private string _someVal = "";
public string SomeVal
{
get { return _someVal; }
set { _someVal = value; }
}

protected void Page_Load(object sender, EventArgs e)
{
Response.Write("** Value: " + _someVal + " **<br />");
}
}
When the page loads it does not print anything for _someVal. Anyone
have any ideas why? This one is killing me... Thanks for any help.

May 16 '06 #1
0 1256

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by tascien | last post: by
2 posts views Thread by paul meaney | last post: by
9 posts views Thread by Frank Rizzo | last post: by
5 posts views Thread by Ben | last post: by
12 posts views Thread by Phil Certain | last post: by
reply views Thread by fernandezr | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.