我已经创建了一个用户控件并在asp.net页面中注册了 也用过那个用户控件。一切正常但用户控制 代码重复执行,并且循环继续。我无法做到 找到为什么这个用户控制代码继续执行,任何帮助都将是 非常感谢。
Header.ascx代码
<%@ Control Language="C#" AutoEventWireup="true" Inherits="SSBilling.UserControl.header" %>
<script language="C#" runat="Server">
public void buffer()
{
try
{
Response.Buffer = true;
}
catch
{
}
}
public string cleanupCookie(string cookie)
{
string tmpcookie = cookie.Replace("%28", "(");
tmpcookie = tmpcookie.Replace("%29", ")");
tmpcookie = tmpcookie.Replace("%27", "'");
tmpcookie = tmpcookie.Replace("%2E", ".");
tmpcookie = tmpcookie.Replace("%3F", "?");
tmpcookie = tmpcookie.Replace("%2C", ",");
tmpcookie = tmpcookie.Replace("%5F", " ");
tmpcookie = tmpcookie.Replace("%2D", "-");
tmpcookie = tmpcookie.Replace('_', ' ');
tmpcookie = tmpcookie.Replace("ITEMCLICK2", "itemClick2");
return tmpcookie;
}
</script>
<%
//************************************************************************************************
//* 2012-06-05 HRHC
//* * migration updated
//************************************************************************************************
buffer();
%>
<script language=vbscript>
sub printthis()
window.focus()
window.print()
end sub
sub backbutton()
on error resume next
<%
Response.Write("' " + ((Request.Cookies["mID"] == null) ? String.Empty : Request.Cookies["mID"].Value) + "\r\n");
//response.write "self.parent.document.all.tmp.tmpMenu.value = """ & cleanupCookie(request.cookies("mID")) & """" & vbcrlf
Response.Write("top.document.all.tmp.tmpMenu.value = \"" + cleanupCookie((Request.Cookies["mID"] == null) ? String.Empty : Request.Cookies["mID"].Value) + "\"" + "\r\n");
//response.write " if instr(1, """ & request.cookies("deptlist") & """, "","" & self.parent.document.all.tmp.currDept.value & "","") > 0 then " & vbcrlf
Response.Write(" if instr(1, \"" + ((Request.Cookies["deptlist"] == null) ? String.Empty : Request.Cookies["deptlist"].Value) + "\", \",\" & top.document.all.tmp.currDept.value & \",\") > 0 then " + "\r\n");
Response.Write(" if err.number <> 0 then exit sub " + "\r\n");
Response.Write("top.go \"visible\"" + "\r\n");
//response.write "self.parent.document.all.menuadmin.style.visibility = ""visible""" & vbcrlf
Response.Write("else" + "\r\n");
Response.Write("top.go \"hidden\"" + "\r\n");
//response.write "self.parent.document.all.menuadmin.style.visibility = ""hidden""" & vbcrlf
Response.Write(" end if " + "\r\n");
//what?
//Session("CurrentUserAdmin") = "Y"
%>
end sub
' 2012-04-04 HRHC
' - modified to avoid scripting error after migrated
' the following if statement only works when the
' child and parent frames are under the same domain
'----------------------------------------------------
'If IsObject(self.parent.document.frames) Then
' If self.parent.document.frames.length = 0 Then
' loc = InStr(8, self.location.href, "/")
' loc = Mid(self.location.href, loc)
'
' location.href = "/default.asp?loc=" & loc
' Else
' Call backbutton
' End If
'End If
</script>
<script type="text/javascript">
if (top === self) {
/*
2012-08-18 HRHC
- no in the trinity frameset (both zone and new app), call the default page.
this will no longer be used after app migrated
*/
var loc = "";
top.location = "/default.aspx?loc=" + loc;
}
else {
/*
- in the frameset, do nothing
*/
}
</script>
<link REL="stylesheet" TYPE="text/css" HREF="/include/content.css">
<%
//response.write "hello from header.inc<br />"
%>
在asp.net页面中注册如下:
<%@ Register TagPrefix="uc" TagName="header"
Src="~/UserControl/header.ascx" %>
并像这样调用了header.ascx:
<uc:header id="ucHeader" runat="server"></uc:header>
谢谢!