Hi,
I am trying to convert my classic asp code to .net. I have created user controls and put following code in one of the user controls. -
<div id="buttons">
-
<ul id="topImages" class="menu" style="margin-left: -2px;">
-
<li>
-
<img id="home" alt="Home" class="top" onclick="javascript:location.href='default.asp'" onmouseout="changeImage(this.id,'home_top<%=home%>.png');" onmouseover="changeImage(this.id,'home_top_over.png');" src="http://bytes.com/images/home_top<%=home%>.png" ></li>
-
<li><img id="web" alt="Services" class="top" onclick="javascript:location.href='services.asp'" onmouseout="changeImage(this.id,'services_top<%=services%>.png');" onmouseover="changeImage(this.id,'services_top_over.png');" src="http://bytes.com/images/services_top<%=services%>.png" >
-
</li>
-
</ul></div>
and if my home page I have some code like this. -
-
<%@ Register TagPrefix="uc" TagName="topMenu" Src="~/inc/topMenu.ascx" %>
-
-
<%
-
Dim home, services As String
-
-
home = "_selected"
-
services = ""
-
%>
-
All my user controls are in a sub folder called "inc". In the topMenu user control it is giving me errors that it cannot recognize home and services variable.
What I need to do to make it work.
Thanks
6 2330
Could you please post the first line in your ASP page so that I can see how your project's configured.
If your project's configured to have 2 files created for your page (the ASP code and the VB.NET code in separate files) then you'll have to move the code in the <% %> to the VB.NET Code file. In this case your fist line in the page will have a CodeBehind attribute pointing to the VB file that should contain the page's VB.NET code. For example: - <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="ScratchPad.WebForm1" %>
If your project's not configured this way, then I believe you need to include script tags (<script runat="server"><script>) instead of the <% %>.
For example: -
<%@ Page Language="VB" %>
-
<script runat="server">
-
Sub Button1_Click(ByVal sender As Object, _
-
ByVal e As System.EventArgs)
-
Label1.Text = "Server click handler called."
-
End Sub
-
</script>
-
-
<body>
-
<form id="form1" runat="server">
-
<asp:Button ID="Button1" Runat="server"
-
OnClick="Button1_Click"
-
OnClientClick="return confirm('Ready to submit.')"
-
Text="Test Client Click" />
-
<br />
-
<asp:Label ID="Label1" Runat="server" text="" />
-
</form>
-
</body>
-
</html>
Just post your first line and we'll be able to help you better.
-Frinny
This is the default.aspx code - <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
-
<%@ Register TagPrefix="uc" TagName="homeText" Src="~/inc/homeText.ascx" %>
-
<%@ Register TagPrefix="uc" TagName="pageHeader" Src="~/inc/header.ascx" %>
-
<%@ Register TagPrefix="uc" TagName="leftMenu" Src="~/inc/leftMenu.ascx" %>
-
<%@ Register TagPrefix="uc" TagName="footer" Src="~/inc/footer.ascx" %>
-
<%@ Register TagPrefix="uc" TagName="headTags" Src="~/inc/headTags.ascx" %>
-
<%@ Register TagPrefix="uc" TagName="topMenu" Src="~/inc/topMenu.ascx" %>
-
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head runat="server">
-
<title>Omair Tech & Designs</title>
-
<uc:headTags ID="headTags" runat="server" />
-
</head>
-
-
<%
-
Dim home, solutions, services, support, about, contact As String
-
-
home = "_selected"
-
solutions = ""
-
services = ""
-
support = ""
-
about = ""
-
contact = ""
-
%>
-
-
<body>
-
<form id="userControlForm" runat="server">
-
<table id="mainTable" align="center" border="0">
-
<tbody>
-
<tr>
-
<td>
-
<uc:pageHeader ID="pageHeader" runat="server" />
-
<uc:topMenu id="topMenu" runat="server" />
-
-
<table id="mainContainer" border="0" cellspacing="0px">
-
<tbody>
-
<tr>
-
<!-- Left Menu -->
-
<uc:leftMenu ID="leftMenu" runat="server" />
-
-
<td id="mainContainerTextArea" valign="top">
-
<uc:homeText id="homeText" runat="server" />
-
-
</td>
-
</tr>
-
</tbody>
-
</table>
-
</td>
-
</tr>
-
<uc:footer ID="footer" runat="server" />
-
</tbody>
-
</table>
-
</form>
-
</body>
-
</html>
And this is the topMenu.ascx code. Every user control is in "inc" folder. - <%@ Control Language="VB" AutoEventWireup="false" CodeFile="topMenu.ascx.vb" Inherits="inc_topMenu" %>
-
-
<div id="buttons">
-
<ul id="topImages" class="menu" style="margin-left: -2px;">
-
<li>
-
<img id="home" alt="Home" class="top" onclick="javascript:location.href='default.aspx'" onmouseout="changeImage(this.id,'home_top<%=home%>.png');" onmouseover="changeImage(this.id,'home_top_over.png');" src="images/home_top<%=home%>.png" >
-
</li>
-
<li>
-
<img id="web" alt="Services" class="top" onclick="javascript:location.href='services.aspx'" onmouseout="changeImage(this.id,'services_top<%=services%>.png');" onmouseover="changeImage(this.id,'services_top_over.png');" src="images/services_top<%=services%>.png" >
-
</li>
-
<li>
-
<img id="app" alt="Solutions" class="top" onclick="javascript:location.href='solutions.aspx'" onmouseout="changeImage(this.id,'solutions_top<%=solutions%>.png');" onmouseover="changeImage(this.id,'solutions_top_over.png');" src="images/solutions_top<%=solutions%>.png" >
-
</li>
-
<li>
-
<img id="network" alt="Support" class="top" onclick="javascript:location.href='support.aspx'" onmouseout="changeImage(this.id,'support_top<%=support%>.png');" onmouseover="changeImage(this.id,'support_top_over.png');" src="images/support_top<%=support%>.png" >
-
</li>
-
<li>
-
<img id="about" alt="About us" class="top" onclick="javascript:location.href='aboutus.aspx'" onmouseout="changeImage(this.id,'about_top<%=about%>.png');" onmouseover="changeImage(this.id,'about_top_over.png');" src="images/about_top<%=about%>.png" >
-
</li>
-
<li>
-
<img id="consult" alt="Contact Us" class="top" onclick="javascript:location.href='contact.aspx'" onmouseout="changeImage(this.id,'contact_top<%=contact%>.png');" onmouseover="changeImage(this.id,'contact_top_over.png');" src="images/contact_top<%=contact%>.png" >
-
</li>
-
</ul>
-
</div>
When you're viewing the ASPX page (in design view not the ASPX code)...double click on the page.
This will open the Default.aspx.vb.
Your code belongs in the Default.aspx.vb file, not in the Default.aspx file.
You need to move the following into the .vb file: -
Dim home, solutions, services, support, about, contact As String
-
-
home = "_selected"
-
solutions = ""
-
services = ""
-
support = ""
-
about = ""
-
contact = ""
I would recommend using proper scope for your variables. So, in your Default.aspx.vb file you should have something like: -
Partial Public Class _Default
-
Inherits System.Web.UI.Page
-
-
Private solutions, services, support, about, contact As String
-
Private home As String = "_selected"
-
-
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
-
-
End Sub
-
End Class
-
Oh wait a sec!
The variables that you've defined in your Default page will not be accessible in your UserControl
You either need to move these variables to the User Control's .vb file....or you need to place them into the web.config file so that they can be accessed throughout every UserControl or Page in the project.
Actually I was able to fix it using following way -
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="topMenu.ascx.vb" Inherits="inc_topMenu" %>
-
-
<%
-
-
Dim home, solutions, services, support, about, contact, selectedPage As String
-
-
selectedPage = Request.Url.ToString
-
selectedPage = selectedPage.Substring(selectedPage.LastIndexOf("/") + 1)
-
-
Select Case selectedPage
-
Case "default.aspx"
-
home = "_selected"
-
Case "solutions.aspx"
-
solutions = "_selected"
-
Case "services.aspx"
-
services = "_selected"
-
Case "support.aspx"
-
support = "_selected"
-
Case "about.aspx"
-
about = "_selected"
-
Case "contact.aspx"
-
contact = "_selected"
-
End Select
-
%>
-
-
<div id="buttons">
-
<ul id="topImages" class="menu" style="margin-left: -2px;">
-
<li>
-
<img id="home" alt="Home" class="top" onclick="javascript:location.href='default.aspx'" onmouseout="changeImage(this.id,'home_top<%=home%>.png');" onmouseover="changeImage(this.id,'home_top_over.png');" src="images/home_top<%=home%>.png" >
-
</li>
-
<li>
-
<img id="web" alt="Services" class="top" onclick="javascript:location.href='services.aspx'" onmouseout="changeImage(this.id,'services_top<%=services%>.png');" onmouseover="changeImage(this.id,'services_top_over.png');" src="images/services_top<%=services%>.png" >
-
</li>
-
<li>
-
<img id="app" alt="Solutions" class="top" onclick="javascript:location.href='solutions.aspx'" onmouseout="changeImage(this.id,'solutions_top<%=solutions%>.png');" onmouseover="changeImage(this.id,'solutions_top_over.png');" src="images/solutions_top<%=solutions%>.png" >
-
</li>
-
<li>
-
<img id="network" alt="Support" class="top" onclick="javascript:location.href='support.aspx'" onmouseout="changeImage(this.id,'support_top<%=support%>.png');" onmouseover="changeImage(this.id,'support_top_over.png');" src="images/support_top<%=support%>.png" >
-
</li>
-
<li>
-
<img id="about" alt="About us" class="top" onclick="javascript:location.href='aboutus.aspx'" onmouseout="changeImage(this.id,'about_top<%=about%>.png');" onmouseover="changeImage(this.id,'about_top_over.png');" src="images/about_top<%=about%>.png" >
-
</li>
-
<li>
-
<img id="consult" alt="Contact Us" class="top" onclick="javascript:location.href='contact.aspx'" onmouseout="changeImage(this.id,'contact_top<%=contact%>.png');" onmouseover="changeImage(this.id,'contact_top_over.png');" src="images/contact_top<%=contact%>.png" >
-
</li>
-
</ul>
-
</div>
-
Yeah, you had to move the variables into the correct place to work.
I would still recommend properly using the .vb file associated with the aspx page.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: mustafa |
last post by:
Dear sir ,
I have built my application in visual basic 6.0 and
crystal Report8.5 , Now i migrated my application to
VB.net using the upgrade wizard.My visual basic form is
upgraded to vb.net...
|
by: Armand Karlsen |
last post by:
I have a website ( http://www.zen62775.zen.co.uk ) that I made HTML 4.01
Transitional and CSS compliant, and I'm thinking of converting it into XHTML
to learn a little about it. Which XHTML variant...
|
by: prabha |
last post by:
Hello Everybody,
I have to conert the word doc to multiple html files,according to the templates in the word doc.
I had converted the word to xml.Also through Exsl ,had finished the multiple...
|
by: Robert |
last post by:
I have a series of web applications (configured as separate applications) on
a server.
There is a main application at the root and then several virtual directories
that are independant...
|
by: Mary |
last post by:
Hi,
Does anyone know of any software out there that would convert an application
written in VBScript to either VB.NET or C#/C++ quite quickly for me, or will
I have to re-write the application...
|
by: Map Reader |
last post by:
Greetings,
I am converting an old VB6 application to use .NET. One of the old controls
loads icons from the disk and displays them. However, the transparent color
turns to blue somewhere in the...
|
by: Frederik Vanderhaeghe |
last post by:
Hi,
I have a problem converting text to a double. Why doesn't the code work:
If Not (txtdocbedrag.Text = "") Then
Select Case ddlBedrag.SelectedIndex
Case 0
Case 1
|
by: Tor Aadnevik |
last post by:
Hi,
I have a problem converting values from Single to double.
eg. When the Single value 12.19 is converted to double, the result is
12.1899995803833.
Anyone know how to avoid this?
Regards...
|
by: gg9h0st |
last post by:
i'm a newbie studying php.
i was into array part on tutorial and it says
i'll get an array having keys that from member variable's name
by converting an object to array.
i guessed "i can...
|
by: shenanwei |
last post by:
DB2 V8.2 on AIX, type II index is created.
I see this from deadlock event monitor.
5) Deadlocked Connection ...
Participant no.: 2
Lock wait start time: 09/18/2006 23:04:09.911774
.........
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |