I just want to know why I get this error at Line # 1. But when I try to remove the comment of the Try Catch, the error transfer to Line # 5, which is the try catch.
I don't think this error occurs because of your aspx. you must have a "using" code in your code behind at a place other than at the top.
Using statements should be at the top of the code behind. If you don't understand what I'm saying, please share your code behind so we can point out where the error is.
Imports GlobalClass.global_class
Imports _DataBinding.databinding
Imports _get_variable.get_variable
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Try
If Not IsPostBack Then
Call cmbGetCompanies(cmbCompany)
End If
'Call oWeb()
If GetQString("UName") <> "" Then
txtUserName.Text = GetQString("UName")
'cmdLogin_onClick("", Ev)
End If
Catch Exp As Exception
WebCtrl.SetMessage(Exp)
End Try
End Sub
End Class
hikaru1207
Member
1 Points
17 Posts
Error : 'Imports' statement must precede any declarations
Feb 22, 2013 11:59 PM|LINK
Hi Experts,
I just want to know why I get this error at Line # 1. But when I try to remove the comment of the Try Catch, the error transfer to Line # 5, which is the try catch.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html> <%--<%Try%>--%> <html> <head> <title> </title> <link href="css/global.css" rel="stylesheet" type="text/css" /> <link href="css/tab.css" rel="stylesheet" type="text/css" /> <link href="css/menu.css" rel="stylesheet" type="text/css" /> <script language="vb" runat="server" src="~/App_Code/global.vb"></script> <%--<script language="vb" runat="server" src="~/vb/portal.vb"></script>--%> <script language="vb" runat="server" src="~/App_Code/get_variable.vb"></script> <script language="vb" runat="server" src="~/App_Code/databinding.vb"></script> </head> <body> <form runat="server" id="f"> <asp:TextBox runat="server" ID="txtTab" Text="tab_1" CssClass="ObjHide"></asp:TextBox> </form> </body> </html> <%--<%Catch xxx As Exception 'WebCtrl.SetMessage(xxx) 'Response.Clear 'Response.Write(xxx.Message) 'Response.Redirect("session_expires.aspx") End Try %>--%>ignatandrei
All-Star
134527 Points
21579 Posts
Moderator
MVP
Re: Error : 'Imports' statement must precede any declarations
Feb 23, 2013 04:36 AM|LINK
Why did you put catch in aspx? ....
hikaru1207
Member
1 Points
17 Posts
Re: Error : 'Imports' statement must precede any declarations
Feb 23, 2013 07:06 AM|LINK
Hi Sir,
I already remove the Try catch in my aspx. Just the same error at line number 1.
Regards,
Ruchira
All-Star
42888 Points
7020 Posts
MVP
Re: Error : 'Imports' statement must precede any declarations
Feb 23, 2013 02:17 PM|LINK
Hello,
I don't think this error occurs because of your aspx. you must have a "using" code in your code behind at a place other than at the top. Using statements should be at the top of the code behind. If you don't understand what I'm saying, please share your code behind so we can point out where the error is.
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.hikaru1207
Member
1 Points
17 Posts
Re: Error : 'Imports' statement must precede any declarations
Feb 23, 2013 02:29 PM|LINK
Hi,
Here's my code behind.
Imports GlobalClass.global_class Imports _DataBinding.databinding Imports _get_variable.get_variable Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load Try If Not IsPostBack Then Call cmbGetCompanies(cmbCompany) End If 'Call oWeb() If GetQString("UName") <> "" Then txtUserName.Text = GetQString("UName") 'cmdLogin_onClick("", Ev) End If Catch Exp As Exception WebCtrl.SetMessage(Exp) End Try End Sub End ClassAppriciate your help.