View Full Version : Help with UserControl

Feb 12, 2010, 11:07 AM
How can I notify the page from usecontrol. If I have textbox and a button on usercontrol when the button clicked I want the page to grab the textbox value and do something with it

Or if I have a grid in control I want to return the row was selected.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="compwizard.Test.test" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
<%@Register Src="~/Test/testc.ascx" TagName="testControl" TagPrefix="uc" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<form id="form1" runat="server">

<ext:ResourceManager ID="ResourceManager1" runat="server" />
<uc:testControl ID="ucTest" runat="server" />


<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="testc.ascx.cs" Inherits="compwizard.Test.testc" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
if (!X.IsAjaxRequest)
// this.Button1.Text = string.Concat("UserControl (", this.Name, ")");

public void GetName()
/// X.Msg.Alert("Name", Search.Text).Show();
/// tell the main page to do something

<ext:TextField ID="Search" runat="server" FieldLabel="search"/>
<ext:Button ID="Button1" runat="server" Text="Search">
<Click Handler="#{DirectMethods}.GetName();" />

Feb 12, 2010, 11:30 AM

There are few ways. For example, using delegates and events. If you type in the Google "ASP.NET page user control delegate communication" then you will see many articles regarding this topic


Feb 12, 2010, 11:34 AM
I thought Coolite uses different ways

Feb 12, 2010, 11:39 AM
I don't think that this topic specific for Coolite. It is "Page - User Control" or "MasterPage - ContentPage" communication problem. Therefore we have no any own way. By the way, what kind of the way did you expect? Any thoughts how to implement it is better than described on those articles?