Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > user control 1.1

Reply
Thread Tools

user control 1.1

 
 
sql sql is offline
Junior Member
Join Date: Apr 2009
Posts: 1
 
      04-02-2009
Hi, i have been couple of months looking for solutions regarding read & write to user control in asp.net 1.1. But i couldnt get any proper solution for my problem.

here is my situation,
I am using VS 2003 in C#, i have a user control with a text box and a aspx page with a button. I add the user control to the aspx page.
Now i am trying to
- read text from text box in user control on button click.
- assign value to text box from the aspx page.

Does anyone know how can i read / assign value of the text box???
Any help appreciated.....

editor.ascx
Quote:
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
editor.ascx.cs
Quote:
protected System.Web.UI.WebControls.TextBox TextBox1;

private void Page_Load(object sender, System.EventArgs e)
{}
public string gettext
{
get
{
return TextBox1.Text;
}
set
{
TextBox1.Text = value;
}
}
.aspx
Quote:
<%@ Register TagPrefix="uc1" TagName="editor" Src="editor.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<uc1:editor id="edi" runat="server"></uc1:editor>
<asp:button id="Button1" runat="server" Text="Button"></asp:button>
<asp:label id="Label1" runat="server"></asp:label>
</form>
</body>
</HTML>
aspx.cs
Quote:
protected System.Web.UI.UserControl edi;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Button Button1;

private void Page_Load(object sender, System.EventArgs e)
{}

private void Button1_Click(object sender, System.EventArgs e)
{
editor edi = (editor)LoadControl("editor.ascx");
//edi.gettext = "test...";
Label1.Text = edi.gettext;
}
 

Last edited by sql; 04-02-2009 at 08:37 AM..
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
User Control to Control Other User Control Jonathan Wood ASP .Net 4 02-02-2010 03:41 PM
persisting changes to a control outside a user control from the user control? Mad Scientist Jr ASP .Net 0 03-22-2006 08:02 AM
Databinding in a user control that contains another user control StraussGuy@hotpop.com ASP .Net 0 01-07-2005 04:55 PM
Event not firing for user control inside user control vatech1993 ASP .Net 4 12-11-2004 02:51 PM
Manipulating a User Control from another User Control Tom Rowton ASP .Net 2 08-01-2003 08:18 PM



Advertisments