您可以在自定义的Kentico全局事件处理程序中执行javascript吗?

使用Kentico的版本10,并尝试从我创建的自定义事件处理程序(身份验证)中调用javascript。代码是:

df1 = df.sort_values('id',kind='quicksort')
df2 = df1.groupby('id').expanding().metric.agg(['sum','mean','std','min','max']).droplevel(1)
df_final = (pd.concat([df1.set_index('id').event,df2],axis=1).reset_index().
              drop_duplicates(subset=['id','event'],keep='last').
              sort_values(['id','event']))

Out[96]:
  id event   sum      mean       std  min  max
3  a     j  12.0  3.000000  1.825742  1.0  5.0
1  a     x   3.0  1.500000  0.707107  1.0  2.0
2  a     z   7.0  2.333333  1.527525  1.0  4.0
4  b     y   3.0  3.000000       NaN  3.0  3.0

而javascript就像这样简单:

public class CustomAuthenticationmodule: Module {
    // Module class constructor,the system registers the module under the name "CustomAuthentication"
    public CustomAuthenticationmodule(): base("CustomAuthentication") {}

    // Contains initialization code that is executed when the application starts
    protected override void OnInit() {
        base.OnInit();

        // Assigns a handler to the SecurityEvents.Authenticate.Execute event
        // This event occurs when users attempt to sign in on the website
        SecurityEvents.Authenticate.Execute += OnAuthentication;
    }

    private void OnAuthentication(object sender,AuthenticationEventArgs e) {
        // Checks if the user was authenticated by the default system. Only continues if authentication succeeded.
        if (e.User != null) {
            // Run client-side javascript function called UpdateCrisp

            // Testing only
            EventLogProvider.LogInformation("Crisp update on login","INFORMATION","Crisp update successful on login");

        }
    }
}

我尝试使用RegisterClientScriptBlock,还尝试向.ascx中的LinkBut​​ton添加OnClientClick事件,但是因为它是用户控件而不是页面,所以也无法使用。有什么建议吗?

liwenlin123 回答:您可以在自定义的Kentico全局事件处理程序中执行javascript吗?

我认为您将无法从Kentico全局系统事件(例如SecurityEvents.Authenticate.Execute)注册客户端脚本,因为您将无权访问ASP.NET页面。在页面的生命周期内可能不会触发系统事件。

如何创建可从客户端代码调用以查看用户是否成功通过身份验证的WebMethod?

迈克

本文链接:https://www.f2er.com/3091522.html

大家都在问