Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language

Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Asp.Net Programming

Can't access to web control textbox property

I built a web control wich has text box and public property that set or get
the text value of that text box.

when i try to access that property i got error:
"Object reference not set to an instance of ..."

the compilation has no detected problem and i do not understand what is the

.ascx (web control)
<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="WebUserControl1.ascx.cs" Inherits="WebGrid.WebUserControl1"
Name:<asp:TextBox id="txtName" runat="server"></asp:TextBox>

public class WebUserControl1 : System.Web.UI.UserControl
  protected System.Web.UI.WebControls.TextBox txtName;
  private string num;
  public string txt
    return txtName.Text;
.aspx (web form that uses the web control
<%@ Register TagPrefix="uc1" TagName="WebUserControl1"
Src="WebUserControl1.ascx" %>
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
Inherits="WebGrid.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
  <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
  <meta name="CODE_LANGUAGE" Content="C#">
  <meta name="vs_defaultClientScript" content="JavaScript">
  <meta name="vs_targetSchema"
 <body MS_POSITIONING="GridLayout">
  <form id="Form1" method="post" runat="server">
   <uc1:WebUserControl1 id="WebUserControl11"
   <asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 64px" runat="server"


private void Button1_Click(object sender, System.EventArgs e)
   WebUserControl1 ctl=new WebUserControl1();

On Jun 6, 9:07 am, Nimrod Rotner <Nimrod

try to call WebUserControl11.txt
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc