views:

284

answers:

1

Hey all,

Can I get some help posting across different pages from a custom control? I've created a custom button that raises it's own click event through the following code:

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Const EventName As String = "button_click"
    Const ArgName As String = "__EVENTARGUMENT"

    If Page.IsPostBack _
    AndAlso Request.Params IsNot Nothing _
    AndAlso Request.Params(ArgName).Trim = EventName Then
        Me.OnClick(Me.this_button, New EventArgs)
    Else
        Me.this_button.Attributes.Add("OnClick", Page.ClientScript.GetPostBackEventReference(Me.this_button, EventName))
    End If

End Sub

How would I go about modifying this to let me post to a different page?

I'd like it to act as close as possible to the System.Web.UI.WebControls.Button property PostBackUrl.

Thanks, Matt

A: 

You can use Cross Page Postbacks.

You can also use the WebForm_DoPostBackWithOptions js method to postback the current page to another page.

Kirtan
That solution makes use of the System.Web.UI.WebControls.Button, which specifically has a property for PostBackUrl. As stated in the title and text of my question, I am using a custom control which has no such property. I'm afraid your answer doesn't help.
Sonny Boy
Thanks, the second option you gave fit the bill nicely.
Sonny Boy