Help with UserControl

  1. #1

    Help with UserControl

    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" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title></title>
    </head>
    <body>
            <form id="form1" runat="server">
            
                <ext:ResourceManager ID="ResourceManager1" runat="server" />
                <uc:testControl ID="ucTest" runat="server" />
            
    
        </form>
    </body>
    </html>
    <%@ 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, ")");
        }
    }
    
    [DirectMethod]
    public void GetName()
    {
        /// X.Msg.Alert("Name", Search.Text).Show();
        /// tell the main page to do something
    }
    
    </script>
    <ext:TextField ID="Search" runat="server" FieldLabel="search"/>
    <ext:Button ID="Button1" runat="server" Text="Search">
        <Listeners>
            <Click Handler="#{DirectMethods}.GetName();" />
        </Listeners>
    </ext:Button>
  2. #2

    RE: Help with UserControl

    Hi,

    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


    http://www.codeproject.com/KB/user-c...erControl.aspx
    http://www.codeproject.com/KB/user-c...rcontrol3.aspx
    http://aspalliance.com/1461_Page_and...munication.all
    http://forums.asp.net/t/1279281.aspx
  3. #3

    RE: Help with UserControl

    I thought Coolite uses different ways
    thanks
  4. #4

    RE: Help with UserControl

    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?

Similar Threads

  1. Replies: 1
    Last Post: May 29, 2013, 6:00 PM
  2. Replies: 8
    Last Post: Feb 15, 2012, 9:04 AM
  3. Replies: 0
    Last Post: Aug 03, 2011, 10:27 PM
  4. Replies: 0
    Last Post: Mar 29, 2011, 3:59 PM
  5. [CLOSED] [1.0] DirectMethod - Page . UserControl . UserControl
    By Patrick in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 25, 2010, 9:33 AM

Posting Permissions