注册启动脚本 [英] Register Startup Script
问题描述
我想验证当前案例是否无法重新分配给系统上的另一个用户,并发送一条通知消息,指示您无法执行此操作.
我的第一个想法是注册一个启动脚本,该脚本将发送警报消息,但是由于某种原因,我无法使其正常工作.
我已经在下面发布了我的代码.也许有人可以指导我找到可行的解决方案.
I want to validate that a current case cannot be reassigned to another user on the system, and send a notification message indicating that you can''t do that.
My first thought is to register a startup script, that will send the alert message, but for some reason, I am not able to get it to work.
I have posted my code below. Perhaps some one can guide me towards a workable solution.
ScriptManager.RegisterStartupScript(this, this.GetType(), "myAlert", "javascript:alert(''Since you are already working on " + Functions.ToString(caseCount) + " cases, you cannot assign any new case to yourself.'');", true);
推荐答案
使用该对象之前必须先声明一个脚本管理器对象.
You have to declare a script manager object first before using it.
ClientScriptManager cs = this.Page.ClientScript
Type rsType = this.GetType()
if (!cs.IsClientScriptInludeRegistered(rsType, "jQuery")) {
cs.RegisterStartupScript("jQuery", "~/script/jquery.js"))
}
就您的JavaScript而言,它看起来像是一条警告消息,指示验证失败.在这种情况下,最佳实践是在按钮对象列表中使用onClientClick,而不注册启动脚本.
As far as your javascript goes, it looks like a alert message that indicates validation has failed. In that case, best practice is to use onClientClick, in the buttons object list, and not register a startup script.
btSubmit.onClientClick = "alert("validation failed"); return false;"
这篇关于注册启动脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!