Thursday, November 20, 2008

Get User Control Value inside .ASPX page

<%@ Control Language="C#" AutoEventWireup="true"

CodeFile="header.ascx.cs" Inherits="UserControl_header" %>

on aspx pages-----------------

incode berhind pages-----------
protected void Page_Load(object sender, EventArgs e)
UserControl huser = header1 as UserControl;

searchlog(ref huser, "text for search");

void searchlog(ref UserControl hd, string text)
Label lb = (Label)hd.FindControl("lbltext");
TextBox txtbox = (TextBox)hd.FindControl("searchtext");
//here i assign text to usercontrol label
lb.Text = text;

//here i write user control text box value on page
Response.Write("User Control Textbox value::" +




  1. My Dear Friend its not working

  2. What I have to do , if I have to load this user control multiple times.
    In that case what how we can get different values from different textboxes..


AJAX, asp,, and sql server security, IntemIndex, C#, Css, DataBinder.Eval, DataKeyNames, Datalist, Datapager, DataSet, DataTable, DropDownList, FindControl, gridview, JavaScript, jquery, Listview, Paging, Regex, RegularExpression, Repeater, Server side validation, Sql Server, timer, timercallback, Validation, XML, xmlnode, XPath