ASP.NET - 自定义控件的跨页发布

时间:2021-08-08 15:25:17

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:

我可以通过自定义控件在不同页面上发布一些帮助吗?我创建了一个自定义按钮,通过以下代码引发它自己的click事件:

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.

我希望它尽可能接近System.Web.UI.WebControls.Button属性PostBackUrl。

1 个解决方案

#1


You can use Cross Page Postbacks.

您可以使用跨页面回发。

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

您还可以使用WebForm_DoPostBackWithOptions js方法将当前页面回发到另一个页面。

#1


You can use Cross Page Postbacks.

您可以使用跨页面回发。

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

您还可以使用WebForm_DoPostBackWithOptions js方法将当前页面回发到另一个页面。