如何调用从母版内的控制javascript函数? [英] How to call a javascript function from a control within a masterpage?
本文介绍了如何调用从母版内的控制javascript函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个登录控制它的母版。当点击登录按钮,我想为一个jQuery的对话框弹出,如果用户的会员大约是在30天内到期,否则它就记录,并将其作为正常的。我无法弄清楚如何做到这一点。我无线本地环路张贴code部分:
下面是JavaScript:
<脚本类型=文/ JavaScript的>
功能showjQueryDialog(){
$(#对话)对话框(开放)。
} $(文件)。就绪(函数(){
$(#对话)。对话框({
的AutoOpen:假的,
模式:真实,
按钮:{更新成员:功能()
{$(本).dialog(亲密); }}
});
});
< / SCRIPT>
登录按钮被称为ibtnLoginButton这里是code的一部分:
//获取用户的个人资料。
的UserProfiles USERPROFILE =
UserProfiles.GetUserProfiles(txtUserName1.Text);//计算时间跨度
时间跨度时间跨度= userProfile.Expiration.Subtract(DateTime.Now);如果(timeSpan.Days小于30)
{
//显示JQuery的对话框这里
}
其他
{
//用登录过程继续。
}
解决方案
这个怎么样?
如果(timeSpan.Days小于30)
{
//显示JQuery的对话框这里
ScriptManager.RegisterClientScriptBlock(此的typeof(页),showExpiration,showjQueryDialog(),真);
}
I have a masterpage with a Login Control in it. When the Login button is clicked, I would like for a JQuery Dialog to popup if the user's membership is about to expire within 30 days, else it will just log them in as normal. I can't figure out how to do it. I wll post parts of code:
Here is the javascript:
<script type="text/javascript">
function showjQueryDialog() {
$("#dialog").dialog("open");
}
$(document).ready(function() {
$("#dialog").dialog({
autoOpen: false,
modal: true,
buttons: { "Renew Membership": function()
{ $(this).dialog("close"); } }
});
});
</script>
The login button is called ibtnLoginButton and here is part of the code:
//Grab the user profile.
UserProfiles userProfile =
UserProfiles.GetUserProfiles(txtUserName1.Text);
//Calculate the Time Span
TimeSpan timeSpan = userProfile.Expiration.Subtract(DateTime.Now);
if (timeSpan.Days < 30)
{
//Show JQuery Dialog Here
}
else
{
//Continue with Login Process.
}
解决方案
how about this?
if (timeSpan.Days < 30)
{
//Show JQuery Dialog Here
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "showExpiration", "showjQueryDialog()", true);
}
这篇关于如何调用从母版内的控制javascript函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文