473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

User Control without Visual Studio

Hiya
Im trying to get a user control working in mono/ASP.NET.

....I have no problem getting a basic control up and working and using
it declaratively in a hosting page's .aspx file.
But for the life of me I can't figure out how to access that control
from the hosting page's code behind file. That is, I would like to set
some of the properties of that control at runtime (say, in Page_Load)
instead of setting the to hardcoded values in the hosting page's aspx
file.
When following all the examples on the web on how to do this, it looks
like you should simply be able to declare a variable in the hosting
page's aspx.cs file of the class type of your control.. then just
reference that variable someplace like Page_Load. This blows up in
mono - the reference to your control class type is not recognized in
the hosting file's aspx.cs file. (I believe Visual Studio precompiles
your control class for you and add's whatever is needed in your hosting

file so that it recognizes your control class. However, I am not
exactly sure what it adds
to the files to make this happen automagically. I would love to know!)
At this point I'm led me to believe that I need my user control to be
compiled and sitting in my applications /bin directory and to add the
appropriate "using" statement to the top of the hosting page's aspx.cs
file. .. so that when my hosting page's aspx.cs file is compiled, the
compiler will recognize my class type and let me access it
programatically.
I compiled my control class, and made a few changes to the directives
at the top of my control's acsx page as well as the hosting page's aspx

page, but now XSP is throwing an internal server error.
ANY HELP WOULD BE APPRECIATED!!
Here are tiny snippets of code to illustrate what I am doing
===== the control ======
=== ascx.cs ===
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MPI.Util.LoggerTypes;
namespace MPI.Testing {
public class FilterList : UserControl {
public string MyText {
get { return yyy.Text; }
set { yyy.Text = value; }
}
}

}
=== ascx ===
<%@ Control language="c#" Inherits="MPI.Testing.FilterList"
AutoEventWireup="true" %>

<asp:Panel id="xxx" runat="server" borderStyle="dotted">
<asp:Label id="yyy" runat="server" text="default" />
</asp:Panel>
============= the hosting page ============
=== aspx.cs ===
using System;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using MPI.Testing;
namespace MPI {
public class TestPage : Page {
FilterList f;
protected void Page_Load(object sender, EventArgs e) {
f.MyText = "yippee!";
}
protected void Page_PreRender(object sender, EventArgs e) {
}
}

}
=== aspx ===
<%@ Page language="c#" src="test.aspx.cs" Inherits="MPI.TestPage"
AutoEventWireup="true" %>
<%@ Register TagPrefix="mpi" TagName="test" assembly="filterlist" %>

<form id="theForm" method="post" runat="server">
<mpi:test id="foo" runat="server" MyText="zot"/>
</form>

Apr 30 '06 #1
0 1189

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: migue | last post by:
way below newbie level: I know nothing about .Net. Have a VB6 client-server application (business app, inventory, purchasing, invoicing, etc.) and am considering converting it to VB.Net at a...
5
by: Marcel Gelijk | last post by:
Hi, I am trying to create a User Control that is located in a seperate class library. The User Control contains a textbox and a button. The page generates an exception when it tries to access...
4
by: migue | last post by:
way below newbie level: I know nothing about .Net. Have a VB6 client-server application (business app, inventory, purchasing, invoicing, etc.) and am considering converting it to VB.Net at a...
3
by: jonathan.beckett | last post by:
I have been experimenting with placing user controls (using Windows Forms controls) into an ASP.NET webpage - and am completely stuck. I can get a blank user control to work, but nothing beyond...
3
by: Jonathan Wood | last post by:
I could really use some help on this. First of all, I want to create a Web control where I render the control completely from scratch based on information from a database. In the book...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.