开发者

Umbraco switching to https and calling a code behind event on login

开发者 https://www.devze.com 2023-02-10 15:17 出处:网络
Have the below code to switch requests from ‘http’ to ‘https’ when user clicks on a button. This is to protect user/password info before it is sent to the server. In the server, should call the co

Have the below code to switch requests from ‘http’ to ‘https’ when user clicks on a button. This is to protect user/password info before it is sent to the server. In the server, should call the code behind associated to the button but is not doing it. On pages that are NOT under Umbraco this code works fine.

Control:

<asp:ImageButton ID="btnLogin" runat="server" OnClick="btnLogin_Click" ... />

Code behind:

protected void Page_Load(object sender, EventArgs e)
{
    PostBackOptions pbOptions = new PostBackOptions(btnLogin);
    pbOptions.ActionUrl = Request.Url.ToString().Replace("http://", "https://");
    btnLogin.Attributes.Add("onclick", "this.disabled = true; + Page.ClientScript.GetPostBackEventReference(pbOptions) + ";");
}

protected void btnLogin_Click(object sender, ImageClickEventArgs e)
{
   want to execute that code
}

If put this code in an Umbraco page, when click on the login button the request changes to ‘https’, page is 开发者_开发技巧post to the server but the btnLogin_Click event is NOT called.

Is there something need to change to make this work in Umbraco? Does anybody know a solution / work around to make ‘btnLogin_Click’ to be executed? Or any idea where I can look to find the problem?

Thanks


Have you tried adding in your Page_Load:

btnLogin_Click += new ImageClickEventHandler(btnLogin_Click);

You may need to add this, as unless you have AutoEventWireup="true" specified in your usercontrol/masterpage declaration, it won't be automatically fired on postback.

HTH,

Benjamin

0

精彩评论

暂无评论...
验证码 换一张
取 消