问题描述
您好,程序员们,我现在对我的编码有些困惑,所以我正在寻求您的帮助.我要完成的工作是从服务器端的主页执行我的JavaScript.这是我在显示模式对话框(母版页)上有关javascript的代码
Hello fellow programmers, Im a little confused right now on my coding so I am seeking your help. What I am trying to accomplish to execute my javascript from my master page on server side. Here is my code on javascript on show modal dialog (master page)
function OpenPopup() {
if (window.showModalDialog) {
window.showModalDialog("PopUp.aspx", "PopUp",
"dialogWidth:550px;dialogHeight:300px,window.location = window.location;");
window.location.reload();
} else {
window.open('PopUp.aspx', 'name', 'height=350,width=600,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes');
}
}
</script>
现在,我尝试在下面的代码上执行我的javascript,这是我的试用代码,但到目前为止没有任何效果.请帮忙
Now I am trying to execute my javascript on code behind here is my trial code but so far nothing is working. Please help
If e.CommandName = "cmdAdd" Then
Dim addimage As ImageButton = DirectCast(e.CommandSource.FindControl("ImageAdd"), ImageButton)
Dim coursecatId As String = addimage.CommandArgument
Session("AddChecking") = "1"
Session("AddCourseCatID") = coursecatId
Session("AddYear") = drpdwnYear.Text
Session("AddDiscipline") = DropDownList1.SelectedValue
'addimage.Attributes.Add("onclick", "javascript:return OpenPopup()")
'If (Not ClientScript.IsStartupScriptRegistered("OpenPopup")) Then
'Page.ClientScript.RegisterStartupScript(Me.GetType(), "Popup", "OpenPopup();", True)
'End If
'Master.Page.ClientScript.RegisterStartupScript(Me.[GetType](), "OpenPopup", "window.showModalDialog('PopUp.aspx','','');", True)
'dialogWidth:550px;dialogHeight:300px,window.location = window.location;
'Dim script = "var $dialog = $('<div></div>').html('This dialog will show every time!').dialog({autoOpen: false,title: 'Basic Dialog'});$dialog.dialog('open');"
'Master.Page.ClientScript.RegisterStartupScript(Me.GetType(), "OpenPopup();", script, True)
'Dim script = ("OpenPopup();")
'Master.Page.ClientScript.RegisterStartupScript([GetType](), Guid.NewGuid().ToString(), script, True)
Else
请注意, addimage.attribute.add(...)可以正常工作,但是我必须双击将使用户感到沮丧.我不能在rowdatabound上使用它,因为我需要会话,所以我真正需要的是RegisterStartupScript.
感谢和更多的力量
note that addimage.attribute.add(...) is working but I have to double click which will kinda frustrate the user. I cannot use it on rowdatabound cause I need the sessions so what I really need is RegisterStartupScript.
thanks and more power
推荐答案
请注意, addimage.attribute.add(...)可以正常工作,但是我必须双击将使用户感到沮丧.我不能在rowdatabound上使用它,因为我需要会话,所以我真正需要的是RegisterStartupScript.
谢谢,还有更多力量
note that addimage.attribute.add(...) is working but I have to double click which will kinda frustrate the user. I cannot use it on rowdatabound cause I need the sessions so what I really need is RegisterStartupScript.
thanks and more power
这篇关于window.showModalDialog在后面的代码上执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!