Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

asp.net VB why am I getting Name '' is not declared. ?

Posted on 2010-09-19
7
Medium Priority
?
654 Views
Last Modified: 2012-05-10
On my page I am assigning the ImageUrl to n asp:Image tag with ID of slide1. But when I try to run the page I get the error:

Name 'slide1' is not declared.

what do I need to do to declare this?

Page:
<asp:Image ID="slide1" runat="server" />

code behind:
slide1.ImageUrl = "slides/" & reader_slides.Item("slide").ToString()


Page code:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" ContentType="text/html" ResponseEncoding="utf-8" %>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<link href="css/styles.css" rel="stylesheet" type="text/css" />

<!-- Begin Scripts-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="js/s3Slider.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('#slider').s3Slider({
            timeOut: 6000
        });
    });
</script>

	
	<script type="text/javascript" src="js/jquery-easing-1.3.pack.js"></script>
	<script type="text/javascript" src="js/jquery-easing-compatibility.1.2.pack.js"></script>
	<script type="text/javascript" src="js/coda-slider.1.1.1.pack.js"></script>
	
	<script type="text/javascript">
var theInt = null;
		var $crosslink, $navthumb;
		var curclicked = 0;
		
		theInterval = function(cur){
			clearInterval(theInt);
			
			if( typeof cur != 'undefined' )
				curclicked = cur;
			
			$crosslink.removeClass("active-thumb");
			$navthumb.eq(curclicked).parent().addClass("active-thumb");
				$(".stripNav ul li a").eq(curclicked).trigger('click');
			
			theInt = setInterval(function(){
				$crosslink.removeClass("active-thumb");
				$navthumb.eq(curclicked).parent().addClass("active-thumb");
				$(".stripNav ul li a").eq(curclicked).trigger('click');
				curclicked++;
				if( 6 == curclicked )
					curclicked = 0;
				
			}, 5000);
		};
		
		$(function(){
			
			$("#main-photo-slider").codaSlider();
			
			$navthumb = $(".nav-thumb");
			$crosslink = $(".cross-link");
			
			$navthumb
			.click(function() {
				var $this = $(this);
				theInterval($this.parent().attr('href').slice(1) - 1);
				return false;
			});
			
			theInterval();
		});
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
    </script>
    
<script type="text/javascript" src="js/countdownpro.js" defer="defer"></script>
<meta scheme="countdown1" name="h_mindigits" content="2"/>
<meta scheme="countdown1" name="m_mindigits" content="2"/>
<meta scheme="countdown1" name="s_mindigits" content="2"/>
<meta scheme="countdown1" name="d_mindigits" content="3"/>
<meta scheme="countdown1" name="d_before" content=""/>
<meta scheme="countdown1" name="d_after" content="&nbsp;"/>
<meta scheme="countdown1" name="d_unit" content=""/>
<meta scheme="countdown1" name="d_units" content=""/>
<meta scheme="countdown1" name="h_before" content="&nbsp;&nbsp;"/>
<meta scheme="countdown1" name="h_after" content="&nbsp;"/>
<meta scheme="countdown1" name="h_unit" content=""/>
<meta scheme="countdown1" name="h_units" content=""/>
<meta scheme="countdown1" name="m_before" content="&nbsp;&nbsp;"/>
<meta scheme="countdown1" name="m_after" content="&nbsp;"/>
<meta scheme="countdown1" name="m_unit" content=""/>
<meta scheme="countdown1" name="m_units" content=""/>
<meta scheme="countdown1" name="s_before" content="&nbsp;&nbsp;"/>
<meta scheme="countdown1" name="s_after" content=""/>
<meta scheme="countdown1" name="s_unit" content=""/>
<meta scheme="countdown1" name="s_units" content=""/>
<!-- End Scripts -->

</head>

<body onload="MM_preloadImages('images/photos_on.png','images/rules_on.png','images/store_on.png','images/center_bar_on.png','images/register_on.png','images/mailing_list_on.png')">
<form id="Form1" runat="server">
<!-- DO NOT MOVE! The following AllWebMenus linking code section must always be placed right AFTER the BODY tag-->
<!-- ******** BEGIN ALLWEBMENUS CODE FOR menu_play3on3 ******** -->
<script type='text/javascript'>var MenuLinkedBy='AllWebMenus [4]',awmMenuName='menu_play3on3',awmBN='DW';awmAltUrl='';</script>
<script charset='UTF-8' src='menu_play3on3.js' type='text/javascript'></script>
<script type='text/javascript'>awmBuildMenu();</script>
<!-- ******** END ALLWEBMENUS CODE FOR menu_play3on3 ******** -->
<!-- <div style="height:100%;"> -->
  <div id="content">&nbsp;<span id='awmAnchor-menu_play3on3'>&nbsp;</span></div>
  <div class="left column">
    <div id="leftcol">&nbsp;</div>
  </div>
<div class="right column">
    <div id="rightcol">&nbsp;</div>
</div>
<!-- </div> -->
<div class="main_content">
<div class="main_left">

<!-- Begin News -->
  <div class="news_holder">
    <img src="images/news_header.gif" alt="news_header" width="180" height="62" />
    <div class="news_text"> 
    <asp:literal runat="server" id="news" />
    </div>
    </div>
<!-- End News -->

<!-- Begin Register -->
<div class="register_holder">
  <!-- <a id="register_linkx" runat="server">Visit W3Schools!</a> -->
  <a id="register_link" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('register','','images/register_on.png',1)" runat="server"><img src="images/register_off.png" alt="Registration" class="border_0" id="register" width="180" /></a>
</div>
<!-- End Register -->

<!-- Begin Mailing List -->
<div class="mailing_list_holder">
  <a id="mailinglist_link" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('mailing list','','images/mailing_list_on.png',1)" runat="server"><img src="images/mailing_list_off.png" class="border_0" alt="mailing list" id="mailing list" width="180" /></a></div>
<!-- End Mailing List -->

</div>

<div class="main_center">

<!-- Begin main slide show -->
  <div class="slide_show_holder">
	<div id="page-wrap">								
	<div class="slider-wrap">
		<div id="main-photo-slider" class="csw">
			<div class="panelContainer">
				<div class="panel" title="Panel 1">
					<div class="wrapper">
                        <img src="main_slides/slide1.jpg" alt="temp" />
						<div class="photo-meta-data">
						  Play 3 on 3<br />
							<span>A youth basketball league for children ages 4-12.</span>
                        </div>
					</div>
				</div>
				<div class="panel" title="Panel 2">
					<div class="wrapper">
                        <img src="main_slides/slide2.jpg" alt="temp" />
						<div class="photo-meta-data">
						  Get in the game<br />
							<span>All skill levels welcome</span>
                        </div>
					</div>
				</div>		
				<div class="panel" title="Panel 3">
										<div class="wrapper">
						<img src="main_slides/slide3.jpg" alt="temp" />
						<div class="photo-meta-data">
						  Volunteer<br />
							<span>If you have a few hours per week and like sports, <br />
sign up to be one of our coaches.</span>
                        </div>
					</div>
				</div>
				<div class="panel" title="Panel 4">
					<div class="wrapper">
                        <img src="main_slides/slide4.jpg" alt="temp" />
						<div class="photo-meta-data">
						  Make friends<br />
							<span>Get introduced to exciting new people</span>
                        </div>
					</div>
				</div>
				<div class="panel" title="Panel 5">
					<div class="wrapper">
                        <img src="main_slides/slide5.jpg" alt="temp" />
						<div class="photo-meta-data">
						  3-2-1 ACTION<br />
							<span>Lead a healthy and active life-style by playing sports or doing other outdoor activities.</span>
                        </div>
					</div>
				</div>
				<div class="panel" title="Panel 6">
					<div class="wrapper2">
						<img src="main_slides/slide6.jpg" alt="temp" width="528px"/>
						<div class="photo-meta-data">
						Register<br />
						<span>Register for the upcoming season online, by mail or in person at one of our local locations.</span>
                        </div>
					</div>
				</div>
			</div>
		</div>
		<a href="#1" class="cross-link active-thumb"><img src="main_slides/slide1.jpg" class="nav-thumb" alt="temp-thumb" width="75"/></a>
  <div id="movers-row">
			<div><a href="#2" class="cross-link"><img src="main_slides/slide2.jpg" alt="temp-thumb" width="75" class="nav-thumb" /></a></div>
			<div><a href="#3" class="cross-link"><img src="main_slides/slide3.jpg" alt="temp-thumb" width="75" class="nav-thumb" /></a></div>
			<div><a href="#4" class="cross-link"><img src="main_slides/slide4.jpg" alt="temp-thumb" width="75" class="nav-thumb" /></a></div>
			<div><a href="#5" class="cross-link"><img src="main_slides/slide5.jpg" alt="temp-thumb" width="75" class="nav-thumb" /></a></div>
			<div><a href="#6" class="cross-link"><img src="main_slides/slide6.jpg" alt="temp-thumb" width="75" class="nav-thumb" /></a></div>
		</div>
	</div>
	</div>
   </div>
<!-- End main slide show -->

<!-- Begin Center Bar -->
<div class="center_bar">
<a id="centerbar_link" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('center_bar','','images/center_bar_on.png',1)" runat="server"><img src="images/center_bar_off.png" alt="Registration Bar" class="border_0" width="579" height="144" id="center_bar" /></a>
</div>

<!-- End Center Bar -->

<!-- Begin Video-->
<div class="video_center">
<object width="500" height="405"><param name="movie" value="http://www.youtube.com/v/7lkUjlB11AA?fs=1&amp;hl=en_US&amp;color1=0xe1600f&amp;color2=0xfebd01&amp;border=1"/><param name="allowFullScreen" value="true"/><param name="allowscriptaccess" value="always"/><embed src="http://www.youtube.com/v/7lkUjlB11AA?fs=1&amp;hl=en_US&amp;color1=0xe1600f&amp;color2=0xfebd01&amp;border=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="405"></embed></object>
</div>

<!-- End Video-->

</div>


<div class="main_right">
<div class="main_right_top"><img src="images/spacer.png" alt="spacer" width="1" height="1" /></div>
<div class="main_right_middle">
  <!-- Begin Slider -->
  <div id="slider">
    <ul id="sliderContent">
      <li class="sliderImage">
        <asp:Image ID="slide1" runat="server" />
        <span class="top"></span>
        </li>
      <li class="sliderImage">
        <asp:Image ID="slide2" runat="server" />
        <span class="top"></span>
        </li>
      <li class="sliderImage">
        <asp:Image ID="slide3" runat="server" />
        <span class="bottom"></span>
        </li>
      <li class="sliderImage">
        <asp:Image ID="slide4" runat="server" />
        <span class="bottom"></span>
        </li>
      <li class="sliderImage">
        <asp:Image ID="slide5" runat="server" />
        <span class="top"></span>
        </li>
      </ul>
   <div class="clear sliderImage">&nbsp;</div>
  </div>
  <!-- End Slider -->
  
  <!-- Begin Countdown Timer -->
  <div class="countdown_bg">
    <span id="countdown1">
        <asp:Literal ID="Counter" runat="server"></asp:Literal>
    </span>
  </div>
  <!-- End Countdown Timer -->
  
  <!-- Begin Photo Tile -->
  <div class="photo_bg">
    <a id="photos_link" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('photo','','images/photos_on.png',1)" runat="server"><img src="images/photos_off.png" alt="Photos" class="border_0" width="191" id="photo" /></a></div>
  <!-- End Photo Tile -->
  
  <!-- Begin Rules Tile -->
  <div class="rule_bg">
    <a id="rules_link" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('rules','','images/rules_on.png',1)" runat="server"><img src="images/rules_off.png" alt="Rules" class="border_0" width="191" id="rules" /></a>
  </div>
  <!-- End Rules Tile -->
  
  <!-- Begin Store Tile -->
  <div class="store_bg">
    <a id="store_link" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('store','','images/store_on.png',1)" runat="server"><img src="images/store_off.png" alt="Play 3on3 Store" class="border_0" height="153" id="store" /></a>
  </div>
  <!-- End Store Tile -->
</div>
<div class="main_right_bottom"><img src="images/spacer.png" alt="spacer" width="1" height="1" /></div>
</div>
</div>

<div class="clear">&nbsp;</div>
<div class="footer_bg">
  <div class="footer_center">&nbsp;</div>

</div>
</form>
</body>
</html>

Open in new window

0
Comment
Question by:elliottbenzle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 3

Expert Comment

by:arweeks
ID: 33710698
> code behind:
> slide1.ImageUrl = "slides/" & reader_slides.Item("slide").ToString()

is there any more in the code behind?  This doesn't look to declare slide1 as anything.  
0
 
LVL 4

Author Comment

by:elliottbenzle
ID: 33710744
here is the rest of the code behind
Imports System.Data.SqlClient
Imports System.Configuration

Partial Class _admin_slider_edit
    Inherits System.Web.UI.Page


    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim fileName As String
        Dim LinkID As Integer
        If slide1.Checked Then
            fileName = FileUpload1.FileName
            LinkID = 1
        ElseIf slide2.Checked Then
            fileName = FileUpload1.FileName
            LinkID = 2
        ElseIf slide3.Checked Then
            fileName = FileUpload1.FileName
            LinkID = 3
        ElseIf slide4.Checked Then
            fileName = FileUpload1.FileName
            LinkID = 4
        ElseIf slide5.Checked Then
            fileName = FileUpload1.FileName
            LinkID = 5
        End If
        If FileUpload1.HasFile Then
            ' = FileUpload1.FileName
            FileUpload1.SaveAs(MapPath("slides/" & fileName))
            Message.Text = "Upload complete."
        Else
            Message.Text = "No files uploaded."
        End If

        Dim conn_slides As SqlConnection
        Dim comm_slides As SqlCommand
        Dim connectionString_slides As String = _
        ConfigurationManager.ConnectionStrings( _
        "play3on3").ConnectionString
        conn_slides = New SqlConnection(connectionString_slides)
        comm_slides = New SqlCommand( _
        "UPDATE slides_side SET slide=@slide_name WHERE id=@LinkID", conn_slides)
        comm_slides.Parameters.Add("@slide_name", System.Data.SqlDbType.NVarChar)
        comm_slides.Parameters("@slide_name").Value = fileName
        comm_slides.Parameters.Add("@LinkID", Data.SqlDbType.Int)
        comm_slides.Parameters.Item("@LinkID").Value = LinkID
        Try
            conn_slides.Open()
            comm_slides.ExecuteNonQuery()
        Catch
            Message.Text = _
            "Error updating the News section!<br />"
        Finally
            conn_slides.Close()
        End Try

    End Sub

    Protected Sub slide1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles slide1.CheckedChanged
        Button1.Enabled = True
        SetFocus(FileUpload1)
    End Sub

    Protected Sub slide2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles slide2.CheckedChanged
        Button1.Enabled = True
        SetFocus(FileUpload1)
    End Sub

    Protected Sub slide3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles slide3.CheckedChanged
        Button1.Enabled = True
        SetFocus(FileUpload1)
    End Sub

    Protected Sub slide4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles slide4.CheckedChanged
        Button1.Enabled = True
        SetFocus(FileUpload1)
    End Sub

    Protected Sub slide5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles slide5.CheckedChanged
        Button1.Enabled = True
        SetFocus(FileUpload1)
    End Sub

    Protected Sub Page_Load_Slides_Edit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim conn_slides As SqlConnection
        Dim comm_slides As SqlCommand
        Dim reader_slides As SqlDataReader
        Dim connectionString_slides As String = _
        ConfigurationManager.ConnectionStrings( _
        "play3on3").ConnectionString
        conn_slides = New SqlConnection(connectionString_slides)
        comm_slides = New SqlCommand( _
        "SELECT slide " & _
        "FROM slides_side ", conn_slides)
        Try
            conn_slides.Open()
            reader_slides = comm_slides.ExecuteReader()
            If reader_slides.Read() Then
                slideimg1.Src = "slides/" & reader_slides.Item("slide").ToString()
                reader_slides.Read()
                slideimg2.Src = "slides/" & reader_slides.Item("slide").ToString()
                reader_slides.Read()
                slideimg3.Src = "slides/" & reader_slides.Item("slide").ToString()
                reader_slides.Read()
                slideimg4.Src = "slides/" & reader_slides.Item("slide").ToString()
                reader_slides.Read()
                slideimg5.Src = "slides/" & reader_slides.Item("slide").ToString()

            End If
            reader_slides.Close()
        Catch
        Finally
            conn_slides.Close()
        End Try

        Response.Redirect("admin_slider_edit.aspx")

    End Sub
End Class

Open in new window

0
 
LVL 12

Accepted Solution

by:
jagssidurala earned 2000 total points
ID: 33710747
I think you are using VS 2008. if we used this make sure that the control should also present in .designer.cs file. if do not find this in designer.cs we get the error which you mentioned.

Cut the <asp:image id="slide1" ...   control and save the file then paste the same. it should work as per my knowlegde.........
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 4

Author Comment

by:elliottbenzle
ID: 33710838
I can't find any designer.cs file. I am using Visual Web Developer 2008.
0
 
LVL 3

Expert Comment

by:a_hassaan
ID: 33711045
write click on your page in the solution explorer and select convert to web application, this will generate the designer.cs file for you
0
 
LVL 3

Expert Comment

by:a_hassaan
ID: 33711269
just a typo... :-)
i meant right click not write click
0
 
LVL 4

Author Closing Comment

by:elliottbenzle
ID: 33713495
Thanks for the help.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question