日期:2014-05-20  浏览次数:20424 次

用母版页做的网页能用page_load事件嘛?
用母版页做的网页能用page_load事件嘛?
我的代码:

<asp:Content   ID= "Content1 "   ContentPlaceHolderID= "ContentPlaceHolder1 "   Runat= "Server ">


    <script     Runat= "Server ">
            Dim   theTitle   As   String
            Dim   theContent   As   String
            Dim   theAuthor   As   String
            Dim   theCopyFrom   As   String
            Dim   theAddTime   As   String
            Sub   page_load(ByVal   Sender   As   Object,   ByVal   E   As   EventArgs)
                   

                    Dim   Cnn   As   SqlConnection
                    Dim   Cmd   As   SqlCommand
                    Dim   DataR   As   SqlDataReader
                    Dim   StrCnn   As   String
                 
                    Dim   codestr   As   String   =   Request.QueryString( "id ")
                    Dim   sql   As   String
                    If   Trim(codestr)   <>   " "   Then
                            StrCnn   =   "server=localhost;uid=as;pwd=;database=myweb "
                            Cnn   =   New   SqlConnection(StrCnn)
                            Cnn.Open()
                            sql   =   "select   *   from   book_info   where   id= "   &   Trim(codestr)
                            Cmd   =   New   SqlCommand(sql,   Cnn)
                            DataR   =   Cmd.ExecuteReader
                            If   DataR.Read()   Then
                                    theTitle   =   DataR( "title ")
                                    theContent   =   DataR( "content ")
                                    theAuthor   =   DataR( "author ")
                                    theCopyFrom   =   DataR( "copyfrom ")