Professional Web Applications Themes

Can we handle events for user controls - ASP.NET Building Controls

Can we handle events for user controls? If so how? Suppose we r creating a user control using a label can we handle a event for the user control label which actually is not present for the build-in label? Or for example for user control( using a DataGrid) can we a scrollevent which actually is not there for the DataGrid? If so how ? Is it that we handle the user control event handling code in the one of DataGrids already present(defined) events? I am new ASP.NET and that too user controls can u help me out. Thank you....

  1. #1

    Default Can we handle events for user controls

    Can we handle events for user controls?

    If so how?
    Suppose we r creating a user control using a label can we
    handle a event for the user control label which actually
    is not present for the build-in label?

    Or for example for user control( using a DataGrid) can we
    a scrollevent which actually is not there for the DataGrid?
    If so how ?
    Is it that we handle the user control event handling code
    in the one of DataGrids already present(defined) events?

    I am new ASP.NET and that too user controls can u help me
    out.
    Thank you.
    Vannela Guest

  2. #2

    Default Re: Can we handle events for user controls

    Hi,

    Check the link below.
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm[/url]
    l/cpconeventsmini-sample.asp

    Thanks,

    sswalia
    MCSD, MCAD, OCA
    "Vannela" <anonymousdiscussions.microsoft.com> wrote in message
    news:05ec01c3a76b$30de7350$a601280aphx.gbl...
    > Can we handle events for user controls?
    >
    > If so how?
    > Suppose we r creating a user control using a label can we
    > handle a event for the user control label which actually
    > is not present for the build-in label?
    >
    > Or for example for user control( using a DataGrid) can we
    > a scrollevent which actually is not there for the DataGrid?
    > If so how ?
    > Is it that we handle the user control event handling code
    > in the one of DataGrids already present(defined) events?
    >
    > I am new ASP.NET and that too user controls can u help me
    > out.
    > Thank you.

    SSW Guest

  3. #3

    Default Re: Can we handle events for user controls

    "SSW" <friendly142004hotmail.com

    Thank you for ur information but i could not find that
    page ie., it not found in that site in that location

    What actaully I want is to handle a event for a user
    control which has to be fired as normal events work for
    server controls ie., the user controls events should not
    be fired in the server control event, is it posssible?

    Thank you
    >-----Original Message-----
    >Hi,
    >
    >Check the link below.
    >[url]http://msdn.microsoft.com/library/default.asp?[/url]
    url=/library/en-us/cpguide/htm
    >l/cpconeventsmini-sample.asp
    >
    >Thanks,
    >
    >sswalia
    >MCSD, MCAD, OCA
    >"Vannela" <anonymousdiscussions.microsoft.com> wrote in
    message
    >news:05ec01c3a76b$30de7350$a601280aphx.gbl...
    >> Can we handle events for user controls?
    >>
    >> If so how?
    >> Suppose we r creating a user control using a label can
    we
    >> handle a event for the user control label which actually
    >> is not present for the build-in label?
    >>
    >> Or for example for user control( using a DataGrid) can
    we
    >> a scrollevent which actually is not there for the
    DataGrid?
    >> If so how ?
    >> Is it that we handle the user control event handling
    code
    >> in the one of DataGrids already present(defined) events?
    >>
    >> I am new ASP.NET and that too user controls can u help
    me
    >> out.
    >> Thank you.
    >
    >
    >.
    >
    Vannela Guest

  4. #4

    Default Re: Can we handle events for user controls

    Hope this will helps.

    Below is a code custome control for Textbox. The event UREvent is raise when we set Text1 Property.

    1) Declare CC as Below.
    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.ComponentModel;

    namespace TextControl
    {
    /// <summary>
    /// Summary description for CCTextBox.
    /// </summary>
    [DefaultProperty("Text1"),
    ToolboxData("<{0}:CCTextBox runat=server></{0}:CCTextBox>")]
    public class CCTextBox : System.Web.UI.WebControls.TextBox
    {
    private string text1;
    public delegate void URDelegate(object sender, System.EventArgs e);
    public event URDelegate urEvent;
    [Bindable(true),
    Category("Appearance"),
    DefaultValue("Surjit S. Walia")]
    public string Text1
    {
    get
    {
    return text1;
    }

    set
    {
    if (urEvent != null)
    urEvent(this, null);
    text1 = value;
    }
    }

    /// <summary>
    /// Render this control to the output parameter specified.
    /// </summary>
    /// <param name="output"> The HTML writer to write out to </param>
    protected override void Render(HtmlTextWriter output)
    {
    base.Render(output);
    }
    }
    }


    2) U can create Instance name CCTextBox1 of this aspx Page and Registor event as below in
    3) Regitor Event as below

    this.CCTextBox1.urEvent += new TextControl.CCTextBox.URDelegate(this.CCTextBox1_u rEvent);

    4) Declare event in Web page as below

    private void CCTextBox1_urEvent(object sender, System.EventArgs e)
    {
    Response.Write("Ur Client Event Works");
    }

    5) On Page_Load Set CC Property.

    CCTextBox1.Text1 ="Hello UR Custome Controls Event Works....";

    It Should Work. It's working at my Place.

    Thanks,

    sswalia


    "Vannela" <anonymousdiscussions.microsoft.com> wrote in message news:07ea01c3a777$2e678970$a101280aphx.gbl...
    > "SSW" <friendly142004hotmail.com
    >
    > Thank you for ur information but i could not find that
    > page ie., it not found in that site in that location
    >
    > What actaully I want is to handle a event for a user
    > control which has to be fired as normal events work for
    > server controls ie., the user controls events should not
    > be fired in the server control event, is it posssible?
    >
    > Thank you
    >
    > >-----Original Message-----
    > >Hi,
    > >
    > >Check the link below.
    > >[url]http://msdn.microsoft.com/library/default.asp?[/url]
    > url=/library/en-us/cpguide/htm
    > >l/cpconeventsmini-sample.asp
    > >
    > >Thanks,
    > >
    > >sswalia
    > >MCSD, MCAD, OCA
    > >"Vannela" <anonymousdiscussions.microsoft.com> wrote in
    > message
    > >news:05ec01c3a76b$30de7350$a601280aphx.gbl...
    > >> Can we handle events for user controls?
    > >>
    > >> If so how?
    > >> Suppose we r creating a user control using a label can
    > we
    > >> handle a event for the user control label which actually
    > >> is not present for the build-in label?
    > >>
    > >> Or for example for user control( using a DataGrid) can
    > we
    > >> a scrollevent which actually is not there for the
    > DataGrid?
    > >> If so how ?
    > >> Is it that we handle the user control event handling
    > code
    > >> in the one of DataGrids already present(defined) events?
    > >>
    > >> I am new ASP.NET and that too user controls can u help
    > me
    > >> out.
    > >> Thank you.
    > >
    > >
    > >.
    > >
    SSW Guest

Similar Threads

  1. Events in dynamic user controls in ASP 2.0
    By Ken Nipper in forum ASP.NET Building Controls
    Replies: 0
    Last Post: January 27th, 03:03 PM
  2. using javascript in User controls to access server controls of the user control
    By Faizan Ahmed in forum ASP.NET Building Controls
    Replies: 1
    Last Post: January 4th, 04:09 PM
  3. How to handle events of controls created at run time?
    By Lalit in forum ASP.NET Building Controls
    Replies: 1
    Last Post: December 23rd, 01:20 AM
  4. Web User Control Events vs. Controls Content
    By Donald Welker in forum ASP.NET Building Controls
    Replies: 0
    Last Post: August 12th, 04:25 PM
  5. Question: Handle Events From Web User Controls
    By VB Programmer in forum ASP.NET General
    Replies: 0
    Last Post: July 3rd, 11:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139