读书人

AJAX的ModalPopupExtender控件弹出窗口

发布时间: 2012-02-29 16:44:11 作者: rapoo

AJAX的ModalPopupExtender控件弹出窗口位置问题...马上给分
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Ajax.aspx.cs " Inherits= "test_Ajax " %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">

<script type= "text/javascript ">

function onYes() {
var id = ' <%=ListBox1.ClientID %> ';
var obj = document.getElementById(id);
var index = obj.selectedIndex;
var a = new Array(2);
if(obj.selectedIndex==-1)
{
document.getElementById( 'Label2 ').innerText = "注意:请先选择一个客户 ";
//alert( "注意:请先选择一个客户 ");
}
else
{
a[0]=obj.options[index].value;
a[1]=obj.options[index].text;
document.getElementById( 'Label1 ').innerText= a[0];
}
}

function onNo() {

document.getElementById( 'Label1 ').innerText = 'Action canceled ';

}

</script>
<style type= "text/css ">
body {
font:normal 10pt/13pt Arial, Verdana, Helvetica, sans-serif;
color:#666;
margin:20px;
}

.modalBackground {
background-color:#000;
filter:alpha(opacity=30);
opacity:0.3;
}

.modalPopup img {
border:solid 5px #fff;
}

.modalPopup-text {
display:block;
color:#000;
background-color:#E6EEF7;
text-align:center;


border:solid 1px #73A2D6;
padding:10px;
}

.modalPopup-text input {
width:75px;
}

.feedback
{
color: #00cc00;
font-weight: 700;
}
</style>
<title> 无标题页 </title>
</head>
<body>
<form id= "form1 " runat= "server ">

<asp:ScriptManager ID= "ScriptManager1 " runat= "server ">
</asp:ScriptManager>
<ajaxToolkit:ModalPopupExtender TargetControlID= "DeleteButton "

PopupControlID= "ConfirmtionPanel "

OkControlID= "YesButton "

OnOkScript= "onYes() "

CancelControlID= "NoButton "

OnCancelScript= "onNo() "

BackgroundCssClass= "modalBackground "
ID= "pop "
runat = "server " >
</ajaxToolkit:ModalPopupExtender>

<asp:Label ID= "Label1 " runat= "server " Text= "Label " CssClass= "feedback "> </asp:Label>
<asp:Button ID= "DeleteButton " runat= "server " Text= "DeleteButton " />
<asp:Panel ID= "ConfirmtionPanel " runat= "server " CssClass= "modalPopup " Style= "display: none ">
<div class= "modalPopup-text ">
<asp:TextBox ID= "TextBox1 " runat= "server " Width= "100px "> </asp:TextBox>
<asp:ImageButton ID= "Button3 " runat= "server " ImageUrl= "~/images/ss.gif " Width= "40px " OnClick= "Button1_Click " />


<asp:ImageButton ID= "YesButton " runat= "server " ImageUrl= "~/images/qd.gif " Width= "40px " />
<asp:ImageButton ID= "NoButton " runat= "server " ImageUrl= "~/images/cancel.gif "
Width= "40px " />
<asp:UpdatePanel ID= "UpdatePanel1 " runat= "server " UpdateMode= "Conditional ">
<ContentTemplate>
<asp:ListBox ID= "ListBox1 " runat= "server " DataSourceID= "ObjectDataSource1 " DataTextField= "ownername "
DataValueField= "ownerid " Height= "150px " Width= "240px "> </asp:ListBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID= "Button3 " EventName= "Click " />
</Triggers>
</asp:UpdatePanel>
</div>
</asp:Panel>

<asp:ObjectDataSource ID= "ObjectDataSource1 " runat= "server " OldValuesParameterFormatString= "original_{0} "
SelectMethod= "Get " TypeName= "BS_CLIENTBLL ">
<SelectParameters>
<asp:Parameter DefaultValue= "% " Name= "ownername " Type= "String " />
</SelectParameters>
</asp:ObjectDataSource>
</form>
</body>
</html>
-----------------------------------------------------
这样写一点问题都没有,弹出的窗口在页面中间,但是如果在页面引入外部js文件的话,如:
<script language= "javascript " src= "JScript.js " type= "text/javascript " > </script>


则弹出窗口会跑到页面左上角,请问怎么解决?

[解决办法]
这个就是看你引入的js是不是有影响布局的代码了
[解决办法]
顶, 难道说内有高手了 1·!~!!!~!~!~!~!

读书人网 >asp.net

热点推荐