你所指的代码指的是客户端代码还是服务器端代码(c# vb.net)

解决方案 »

  1.   

    瞧这个:
    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="BadProfitLoss.aspx.vb" Inherits="CircleStock.BadProfitLoss"%>
    <HTML>
    <HEAD>
    <title></title>
    <meta content="Microsoft Visual Studio .NET 7.0" name="GENERATOR">
    <meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    <!--body MS_POSITIONING="GridLayout" vlink="<% =Application("AppTitleColor")%>"-->
    </HEAD>
    <BODY bgColor="#ffffff" MS_POSITIONING="GridLayout">
    <form id="Form2" runat="server">
    <!-- #include file="include/top.txt" --><TR height="15">
    <TD colspan="2">
    <TABLE cellSpacing="2" cellPadding="2" align="left">
    <TBODY>
    <TR>
    <TD style="FONT-SIZE: 9pt" width="70">
    <div style="WIDTH: 200px"><B><FONT><A href="default.aspx">站点首页 </A>&nbsp;|&nbsp;故障品损益单</FONT></B></div>
    </TD>
    <!--TD style ="FONT-SIZE: 9pt" width = "70"><div  style="WIDTH: 200"><B><FONT color="<% =Application("AppTitleColor")%>"><A href="default.aspx">站点首页 </A>&nbsp;|&nbsp;内部调库单</FONT></B></div> </TD--></TR>
    </TBODY>
    </TABLE>
    </TD>
    </TR>
    <TR>
    <TD colspan="2">
    <HR align="center" width="750" SIZE="1">
    <!--TD colspan="2"><HR align="center" width="750" color="<% =Application("AppHRColor")%>" SIZE="1"--></TD>
    </TR>
    <TR height="300">
    <TD colspan="2" width="100%">
    <TABLE borderColor="black" cellSpacing="1" cellPadding="1" width="100%" bgColor="blue" border="0">
    <TR bgColor="white">
    <TD style="HEIGHT: 20px" align="middle" colSpan="6"><asp:radiobuttonlist id="radlShowListType" runat="server" Font-Names="宋体" Font-Size="X-Small" RepeatDirection="Horizontal" Width="308px" DESIGNTIMEDRAGDROP="416" Height="6px">
    <asp:ListItem Value="1" Selected="True">周转机</asp:ListItem>
    <asp:ListItem Value="2">周转模块</asp:ListItem>
    <asp:ListItem Value="4">周转附件</asp:ListItem>
    </asp:radiobuttonlist></TD>
    </TR>
    <TR bgColor="white">
    <TD colSpan="6">查询条件:
    <asp:dropdownlist id="dropCondition" Runat="server">
    <asp:ListItem Value="1">单据编号</asp:ListItem>
    <asp:ListItem Value="3">制单人</asp:ListItem>
    <asp:ListItem Value="4">制单时间</asp:ListItem>
    <asp:ListItem Value="5">状态</asp:ListItem>
    </asp:dropdownlist>&nbsp;
    <asp:textbox id="txtSearch" Runat="server"></asp:textbox><asp:dropdownlist id="dropSearch" runat="server" Visible="False"></asp:dropdownlist><asp:textbox id="txtSearchForDate" runat="server" Visible="False"></asp:textbox>&nbsp;
    <asp:button id="bntSearch" Runat="server" Text="查询"></asp:button>&nbsp;
    </TD>
    <!--TD><% =now()%></TD--></TR>
    <TR bgColor="white">
    <TD colSpan="6"><asp:panel id="pnlGoods1" Runat="server">
    <asp:Label id="lblMessage" Runat="server"></asp:Label>
    <asp:datagrid id=dgrdGoods width="95%" Runat="Server" OnItemCommand="dgrdGoods_ItemCommand" AllowPaging="True" PageSize="2" OnPageIndexChanged="dgrdGoods_PageIndexChanged" PagerStyle-Mode="NumericPages" PagerStyle-BackColor="<%# me.GridPageBackColor%>" HeaderStyle-BackColor="<%# me.GridHeaderBackColor%>" AutoGenerateColumns="False">
    <HeaderStyle BackColor="#FF9966"></HeaderStyle>
    <Columns>
    <asp:TemplateColumn>
    <HeaderTemplate>
    单据编号
    </HeaderTemplate>
    <ItemTemplate>
    <%# Container.DataItem( "Code" ) %>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn>
    <HeaderTemplate>
    出入库原因
    </HeaderTemplate>
    <ItemTemplate>
    <%# Container.DataItem( "Description" ) %>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn>
    <HeaderTemplate>
    制单人
    </HeaderTemplate>
    <ItemTemplate>
    <%# Container.DataItem( "ApplyMan" ) %>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn>
    <HeaderTemplate>
    制单时间
    </HeaderTemplate>
    <ItemTemplate>
    <%# Container.DataItem( "CheckDate" ) %>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn>
    <HeaderTemplate>
    状态
    </HeaderTemplate>
    <ItemTemplate>
    <%# Container.DataItem( "Status" ) %>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:ButtonColumn Text="修改" CommandName="Edit"></asp:ButtonColumn>
    <asp:ButtonColumn Text="预览" CommandName="Browse"></asp:ButtonColumn>
    <asp:ButtonColumn Text="删除" CommandName="Delete"></asp:ButtonColumn>
    </Columns>
    <PagerStyle BackColor="#FF9966" Mode="NumericPages"></PagerStyle>
    </asp:datagrid>
    </asp:panel></TD>
    </TR>
    <TR bgColor="white">
    <TD align="middle" colSpan="6"><asp:button id="btnNew" runat="server" Height="17px" Text="新建" BackColor="White" BorderStyle="None" Font-Underline="True"></asp:button></TD>
    </TR>
    </TABLE>
    </form>
    </BODY>
    </HTML>
      

  2.   

    以前寫asp網頁時校驗用戶訪問網頁權限時必須在每個asp網頁第一行寫一個inclue語句,包含文件的功能是校驗用戶訪問網頁權限,而在asp.net中只需在一個配置文件中加上inclue語句,之後所有aspx網頁都會執行inclue語句包括的代碼,我是問這個配置文件名是什麼?
    我在Global.asax文件試過,但不起作用.
      

  3.   

    如果定義類的話,那在每個文件還是要加入一些代碼,而我說的那種方法不用對aspx文件做任何修改就可以執行包含文件中的功能.
    我是從去年9月份微軟技術大會里知道asp.net有這個功能,但我那時候還是用其它語言寫數據庫管理程序,所以沒留意,現在要用的時候又記不起來了.
      

  4.   

    do it in global.asax, in HttpApplication's event handlers, or write some HttpModule
      

  5.   

    因為我在global.asax中試過,但沒有實現,可不可以給出一個簡單例子.
      

  6.   

    for authentication purpose, you should be using windows integration or forms-based authentication in ASP.NET, but if you insist, try
        void Application_AcquireRequestState(Object sender, EventArgs E) 
        {
    string[] s = HttpContext.Current.Request.Url.Segments;
            if (s[s.Length-1] != "login.aspx" && (Session["login"] == null || Session["login"] ==""))
    Response.Redirect("login.aspx");
        }