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

D

digitalego

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
 
D

digitalego

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top