By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,714 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,714 IT Pros & Developers. It's quick & easy.

access a user control via a "page src=" .aspx page

P: n/a
Sorry if the title is a little confusing... Here is the problem.

I am working with a "default.aspx" page that uses a user control I
made:

------------------------------
| default.aspx |
------------------------------

<%@ Page language="C#" CodeBehind="ChartPage.cs"
AutoEventWireup="false" Inherits="ChartPage.ChartPageForm" %>
<%@ Register TagPrefix="Acme" TagName="Login"
Src="chartPerformance.ascx" %>
<form runat="server">
<Acme:Login ID="chart1" runat="server" Category="crap crap crap"/>
</form>

------------------------------
| chartPerformance.ascx |
------------------------------

<%@ control inherits = "Graphs.HistogramBenchmark" src =
"chartPerformance.cs" %>
Chart Your Performance:
<ul>
<li>Category: <asp:label id="myCategory" runat="server" /></li>
<li>Rounds Played To Chart: <asp:textbox id="txtRoundsToChart"
runat="server"/></li>
<li># Of Holes Played: <asp:textbox id="txtNumHolesPlayed"
runat="server"/></li>
</ul>
<asp:button text="Chart Performance" OnClick="SubmitBtn_Click"
runat="server"/><br>
<asp:label id="Result" runat="server" />

------------------------------
| chartPerformance.cs |
------------------------------

/*
* Chart Performance Custom User Control
*/
using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Graphs {
// charts the performance of all rounds within search query...
public class HistogramBenchmark : UserControl {
public Label myCategory;

private string _category = "Sample Category";
public string Category {
get { return _category; }
set
{
_category = value;
myCategory.Text = _category;
}
}

public TextBox txtRoundsToChart;
public TextBox txtNumHolesPlayed;
public Label Result;

public void SubmitBtn_Click(Object sender, EventArgs e) {
Result.Text = "<li>Rounds To Chart: " + txtRoundsToChart.Text +
"</li><li># Holes Played: " + txtNumHolesPlayed.Text;
}
}
}

------------------------------
| ChartPage.cs |
------------------------------

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ChartPage {
public class ChartPageForm : Page {
protected System.Web.UI.WebControls.TextBox MyTextBox;
protected System.Web.UI.WebControls.Button MyButton;
protected System.Web.UI.WebControls.Label MyLabel;
// protected Graphs.HistogramBenchmark chart1;

private void Page_Load(Object sender, EventArgs e) {
// i need to access my chart1 that is on the default.aspx
// now i have read that I should use the above naming convention
// so that I can use something like
// chart1.Category="Set category to something....";
}

public void MyButton_Click(Object sender, EventArgs e) {
MyLabel.Text = MyTextBox.Text.ToString();
}
}
}

In short on the ChartPage.cs is there someway I can access the chart1
UserControl and its properties. I have looked everywhere. The IMPORTANT
thing to note is that I DO NOT want to compile anything before using
it, personally I think it is ugly the way you HAVE to compile versions
of your component that you are STILL developing forcing recompiles
etc....

Best Regards,
Terrance A. Snyder

Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Sorry default.aspx should be like the below
------------------------------
| default.aspx |
------------------------------

<%@ Page language="C#" Src="ChartPage.cs"
AutoEventWireup="false" Inherits="ChartPage.ChartPageForm" %>
<%@ Register TagPrefix="Acme" TagName="Login"
Src="chartPerformance.ascx" %>
<form runat="server">
<Acme:Login ID="chart1" runat="server" Category="crap crap crap"/>
</form>
The change was SRC="CharPage.cs"...

Again I still can't access the properties of the Acme:Login UserControl
I added to the default.aspx page from my ChartPage.cs...

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.