使用 Response.Write(<script>alert('OK')</script>); 后 网页的布局变乱了,没有弹出对话框之

W

wzjlg

Unregistered / Unconfirmed
GUEST, unregistred user!
使用 Response.Write(<script>alert('OK')</script>);
后 网页的布局变乱了,没有弹出对话框之间布局是正常的的,弹出后就不行了!急急急急急! ( 积分: 70 )
<br />[?][?][?][?][?] cs文件中的:
Label1.Text = &quot;<script>alert('OK')</script>&quot;;
Response.Write(Label1.Text);
aspx 文件中的
<%@ Page Language=&quot;C#&quot;
AutoEventWireup=&quot;true&quot;
CodeFile=&quot;Default.aspx.cs&quot;
Inherits=&quot;_Default&quot;
%>
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>
<html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;
>
<head runat=&quot;server&quot;>
<title>无标题页</title>
<link href=&quot;StyleSheet.css&quot;
type=&quot;text/css&quot;
rel=&quot;stylesheet&quot;/>
</head>
<body>
<form id=&quot;form1&quot;
runat=&quot;server&quot;>
<div style=&quot;height:50%;background-color:Red&quot;>
<asp:Button ID=&quot;Button2&quot;
runat=&quot;server&quot;
Text=&quot;Button2&quot;
OnClick=&quot;Button2_Click&quot;
/>
<asp:Label ID=&quot;Label1&quot;
runat=&quot;server&quot;
Text=&quot;Label&quot;></asp:Label>
<asp:Button ID=&quot;Button1&quot;
runat=&quot;server&quot;
OnClick=&quot;Button1_Click&quot;
Text=&quot;Button&quot;
/>
<asp:FileUpload ID=&quot;FileUpload1&quot;
runat=&quot;server&quot;
/>

</div>
</form>
</body>
</html>
stylesheet 文件中的
BODY {
BACKGROUND-COLOR: #FFFFFF;
FONT-SIZE: 10pt;
LINE-HEIGHT: normal;
MARGIN-LEFT: 0px;
MARGIN-RIGHT: 0px;
MARGIN-TOP: 0px;SCROLLBAR-FACE-COLOR: LightGray;
SCROLLBAR-SHADOW-COLOR: #ffffff;
SCROLLBAR-3DLIGHT-COLOR: Gainsboro;
SCROLLBAR-ARROW-COLOR: #ffffff;
BORDER-BOTTOM: #ffffff 0px;

SCROLLBAR-DARKSHADOW-COLOR: Gainsboro;
BORDER-COLLAPSE: collapse ;
height:100%;
}
 
好长时间不用 asp.net 了
你可以查看一下弹出后的 IE 源代码,
Response.Write 这句会在 页面的最上面写入,仔细看看就知道了,
然后你是不是可以指定输出呢
 
其实不需要这样的:
Label1.Text = &quot;<script>alert('OK')</script>&quot;;
Response.Write(Label1.Text);
直接这样写就行了:
Response.Write(&quot;<script>alert('OK')</script>&quot;);
 
直接写成这样: Response.Write(&quot;<script>alert('OK')</script>&quot;);
布局还是会乱,并且当DIV有滚动条是时,执行面的语句后,滚动条也没有了,不知道有没有那们大哥遇见过这样的问题
 
string script = &quot;
<!DOCTYPE html PUBLIC / &quot;
-//W3C//DTD XHTML 1.0 Transitional//EN/ &quot;
/ &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd/ &quot;
> <script language=/ &quot;JavaScript/ &quot;
>function OpenQueryFrm(frmWin,width,height) { var me;me = window;window.showModelessDialog(frmWin,me, 'dialogWidth= '+ width + 'px;dialogHeight= '+height+ 'px;help:no;status:no ') } OpenQueryFrm( '../GlobalQuickLook.aspx?db= &quot;
+ strDataBaseName + &quot;
',600,360);
</script > &quot;;
this.Response.Write(script);
這個問題我正好也遇到過,最後是自己用了一個惡心的解決辦法是輸出“DOCTYPE .....”那一串文件頭。
您參考下:http://topic.csdn.net/u/20070111/09/b50f804d-5765-4f9a-8eed-a0faf8688972.html
 
这样
Page.RegisterStartupScript(&quot;Startup&quot;, &quot;<script language='javascript'>alert('您没有登录系统,不能进行录入界面!!');</script>&quot;);
 
顶部