post back event in server control

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default post back event in server control

    how do I get the button event recognized in the post back from a server control ??


    ========code=============

    Public Class MyButton
    Inherits System.Web.UI.Page
    Implements IPostBackEventHandler


    Public Response As HttpResponse = HttpContext.Current.Response


    ' Defines the Click event.
    '-----------------------------
    Public Event Click As EventHandler

    ' OnClick dispatches the event to delegates that
    ' are registered with the Click event.
    ' Controls that derive from MyButton can handle the
    ' Click event by overriding OnClick
    ' instead of attaching a delegate. The event data
    ' is passed as an argument to this method.
    '-----------------------------------------------
    Protected Overridable Sub OnClick(e As EventArgs)
    RaiseEvent Click(Me, e)
    End Sub

    ' Method of IPostBackEventHandler that raises change events.
    '-----------------------------------------------------------
    Public Sub RaisePostBackEvent(eventArgument As String)
    Implements PostBackEventHandler.RaisePostBackEvent
    OnClick(EventArgs.Empty)
    System.Web.UI.Page.ClientScript.RegisterStartupScr ipt(Me.GetType(), "MyScript", _
    "function AlertHello() { alert('Hello'); }", True)
    End Sub 'RaisePostBackEvent

    Public Sub New()
    Response.Write("<INPUT TYPE = submit name = " & Me.UniqueID & " Value = 'Click Me' />")
    End Sub


    End Class


    Jon Paal Guest

  2. Similar Questions and Discussions

    1. Flash Player Post Back data to server
      Hello, I have a flash based application that I am having a data transfer issue with. 1 particular user can access the flash application which...
    2. 2nd attempt - post back event in server control
      my code is not getting successful result. how do I get the server control to recognize a button click event ?? ========code============= ...
    3. Dragging rows without a post back to the server.
      I have been able to create a datagrid that is able to click and drag from one row and drop it onto another to move it above the row dropped on. The...
    4. How to Capture Control Initaited the Post Back.
      Here is my problem, I am using 3 user controls in a page(Test.aspx) which are 1.Header UC 2.Body UC 3.Footer UC HeaderUC has a DropDownList...
    5. Post back and control focus issues
      Hi, This might help : http://www.developer.com/net/asp/article.php/2237431 Natty Gur, CTO Dao2Com Ltd. 28th Baruch Hirsch st. Bnei-Brak...
  3. #2

    Default Re: post back event in server control

    > how do I get the button event recognized in the post back from a server
    > control ??
    Don't use 'Response.Write'.
    But use:

    override CreateChildControls()
    {

    base.CreateChildControls();

    Button btn = new Button;
    btn.Text = ...
    btn.Value = ...
    Controls.Add(btn);

    }


    --
    Happy Hacking,
    Gaurav Vaish | [url]http://www.mastergaurav.com[/url]
    [url]http://www.edujinionline.com[/url]
    [url]http://articles.edujinionline.com/webservices[/url]
    -------------------


    Gaurav Vaish \(www.EduJiniOnline.com\) Guest

Posting Permissions

  • You may not post new threads
  • You may 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