Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > User Control without Visual Studio

Reply
Thread Tools

User Control without Visual Studio

 
 
mivhaelveloz
Guest
Posts: n/a
 
      04-30-2006
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" %>

<aspanel id="xxx" runat="server" borderStyle="dotted">
<asp:Label id="yyy" runat="server" text="default" />
</aspanel>


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is Visual Studio 2005 complict with Visual Studio 2003 rockdale ASP .Net 1 08-23-2006 07:20 PM
Should I write Visual studio 2005 or Visual studio 2003 MCSD =?Utf-8?B?VmlqYXk=?= Microsoft Certification 14 06-30-2006 09:05 AM
Should I write Visual studio 2005 or Visual studio 2003 MCSD =?Utf-8?B?VmlqYXk=?= Microsoft Certification 0 06-29-2006 07:05 PM
Is Visual Studio Team System and Visual Studio Foundation Server are same?. Thirumalai ASP .Net 0 05-22-2006 08:48 AM
visual studio .net 2003 verses visual studio .net 2002 wh ASP .Net 2 01-16-2004 04:54 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57