使用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中的LinkButton添加OnClientClick事件,但是因为它是用户控件而不是页面,所以也无法使用。有什么建议吗?