473,569 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Name not exists when it obviously does.

I am getting an error on a object name that doesn't exist (according to asp.net), but if you look at the trace, it does.

Here is the error:

*************** *************** *************** *************** *************** *************** *
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30451: Name 'txtQuestion' is not declared.

Source Error:

Line 102: Dim positionID as Integer = Session("Positi onID")
Line 103:
Line 104:trace.warn( "txtQuestio n = " & txtQuestion.tex t)
*************** *************** *************** *************** *************** *************** *

Here is the asp code showing it as part of the EditItemTemplat e - so of course it doesn't exist when the page is first displayed(last line shows it):
*************** *************** *************** *************** *************** ***************
<EditItemTempla te>
<table border="1" width="100%" CellPadding="0" CellSpacing="0" style="margin:0 ">
<tr>
<td>
<asp:ImageButto n ID="ExpandButto n" runat="server" Font-Size="2" ImageUrl="../images/expand.gif" Width="16" Height="16" CommandName="Se lect" AlternateText=" Click here to see details"></asp:ImageButton >
</td>
<td>
<asp:ImageButto n ID="CollapseBut ton" visible="false" runat="server" Font-Size="2" ImageUrl="../images/collapse.gif" Width="16" Height="16" CommandName="Se lect" AlternateText=" Click here to see details"></asp:ImageButton >
<asp:label id="PositionID " Visible="false" runat="server" Text='<%# DataBinder.Eval (Container.Data Item, "PositionID ") %>' />
<asp:label id="QuestionUni que" Visible="false" runat="server" Text='<%# DataBinder.Eval (Container.Data Item, "QuestionUnique ") %>' />
</td>
<td width="100%">

<asp:TextBox id="txtQuestion " columns="60" MaxLength="50" runat="server" Text='<%# DataBinder.Eval (Container.Data Item, "Question") %>' />
*************** *************** *************** *************** *************** *************** *

Here is the trace.route showing it (I had to comment out the trace.warn statement to get it):

*************** *************** *************** *************** *************** ************
DataList1System .Web.UI.WebCont rols.DataList52 83100 DataList1:_ctl0 System.Web.UI.W ebControls.Data ListItem9860 DataList1:_ctl0 :_ctl2System.We b.UI.LiteralCon trol1340 DataList1:_ctl0 :ExpandButtonSy stem.Web.UI.Web Controls.ImageB utton1620 DataList1:_ctl0 :_ctl3System.We b.UI.LiteralCon trol460 DataList1:_ctl0 :CollapseButton System.Web.UI.W ebControls.Imag eButton00 DataList1:_ctl0 :_ctl4System.We b.UI.LiteralCon trol130 DataList1:_ctl0 :PositionIDSyst em.Web.UI.WebCo ntrols.Label032 DataList1:_ctl0 :_ctl5System.We b.UI.LiteralCon trol130 DataList1:_ctl0 :QuestionUnique System.Web.UI.W ebControls.Labe l028 DataList1:_ctl0 :_ctl6System.We b.UI.LiteralCon trol590
---> DataList1:_ctl0 :txtQuestion System.Web.UI.W ebControls.Text Box1650 DataList1:_ctl0 :_ctl7System.We b.UI.LiteralCon trol650 DataList1:_ctl0 :_ctl0System.We b.UI.WebControl s.Button670 DataList1:_ctl0 :_ctl8System.We b.UI.LiteralCon trol130 DataList1:_ctl0 :_ctl1System.We b.UI.WebControl s.Button670 DataList1:_ctl0 :_ctl9System.We b.UI.LiteralCon trol1220 DataList1:_ctl0 :DataGrid1Syste m.Web.UI.WebCon trols.DataGrid0 136 DataList1:_ctl0 :_ctl10System.W eb.UI.LiteralCo ntrol600 DataList1:_ctl1 System.Web.UI.W ebControls.Data ListItem400 *************** *************** *************** *************** *************** **************

This does not show up on the first page (as we are not in edit mode yet), but I am getting the error before the first page is executed. We do not go into this subroutine except during editing mode - when the object would exist.

Why would I get the error at this time and how do I get around this?

Thanks

Tom

Nov 19 '05 #1
2 1604
Tom,
It's hard to be sure without more context, but it seems pretty clear that
infact txtQuestion DOES NOT exist. What does exist is
DataList1:_ctl0 :txtQuestion which is quite different. If you want to get a
reference to txtQuestion, you need to do a FindControl("tx tQuestion")
within the edit template.

In other words, what you see as txtQuestion is a control embedded within
other controls (from what you've shown, that's a datalist containing an
editTemplate which contains a textbox). It therefore isnt simply available
as "txtQuestio n". It only exists as "txtQuestio n" as far as the edit
template is concerned. So to get it, you need to do:

private Sub Edit_Command(se nder As Object, e As DataListCommand EventArgs)
...
dim txt as TextBox = ctype(e.Item.Fi ndControl("txtQ uestion"), TextBox)
...
end sub

Karl

P.S. - Option Strict is your friend in VB.Net
--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <ts**********@f tsolutions.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
I am getting an error on a object name that doesn't exist (according to
asp.net), but if you look at the trace, it does.

Here is the error:

*************** *************** *************** *************** *************** *
***************
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific error
details and modify your source code appropriately.

Compiler Error Message: BC30451: Name 'txtQuestion' is not declared.

Source Error:

Line 102: Dim positionID as Integer = Session("Positi onID")
Line 103:
Line 104:trace.warn( "txtQuestio n = " & txtQuestion.tex t)
*************** *************** *************** *************** *************** *
***************

Here is the asp code showing it as part of the EditItemTemplat e - so of
course it doesn't exist when the page is first displayed(last line shows
it):
*************** *************** *************** *************** *************** *
**************
<EditItemTempla te>
<table border="1" width="100%" CellPadding="0" CellSpacing="0"
style="margin:0 ">
<tr>
<td>
<asp:ImageButto n ID="ExpandButto n" runat="server" Font-Size="2"
ImageUrl="../images/expand.gif" Width="16" Height="16" CommandName="Se lect"
AlternateText=" Click here to see details"></asp:ImageButton >
</td>
<td>
<asp:ImageButto n ID="CollapseBut ton" visible="false"
runat="server" Font-Size="2" ImageUrl="../images/collapse.gif" Width="16"
Height="16" CommandName="Se lect" AlternateText=" Click here to see
details"></asp:ImageButton >
<asp:label id="PositionID " Visible="false" runat="server"
Text='<%# DataBinder.Eval (Container.Data Item, "PositionID ") %>' />
<asp:label id="QuestionUni que" Visible="false" runat="server"
Text='<%# DataBinder.Eval (Container.Data Item, "QuestionUnique ") %>' />
</td>
<td width="100%">

<asp:TextBox id="txtQuestion " columns="60" MaxLength="50"
runat="server" Text='<%# DataBinder.Eval (Container.Data Item, "Question") %>'
/>
*************** *************** *************** *************** *************** *
***************

Here is the trace.route showing it (I had to comment out the trace.warn
statement to get it):

*************** *************** *************** *************** *************** *
***********
DataList1System .Web.UI.WebCont rols.DataList52 83100
DataList1:_ctl0 System.Web.UI.W ebControls.Data ListItem9860
DataList1:_ctl0 :_ctl2System.We b.UI.LiteralCon trol1340
DataList1:_ctl0 :ExpandButtonSy stem.Web.UI.Web Controls.ImageB utton1620
DataList1:_ctl0 :_ctl3System.We b.UI.LiteralCon trol460
DataList1:_ctl0 :CollapseButton System.Web.UI.W ebControls.Imag eButton00
DataList1:_ctl0 :_ctl4System.We b.UI.LiteralCon trol130
DataList1:_ctl0 :PositionIDSyst em.Web.UI.WebCo ntrols.Label032
DataList1:_ctl0 :_ctl5System.We b.UI.LiteralCon trol130
DataList1:_ctl0 :QuestionUnique System.Web.UI.W ebControls.Labe l028
DataList1:_ctl0 :_ctl6System.We b.UI.LiteralCon trol590
---> DataList1:_ctl0 :txtQuestion
System.Web.UI.W ebControls.Text Box1650
DataList1:_ctl0 :_ctl7System.We b.UI.LiteralCon trol650
DataList1:_ctl0 :_ctl0System.We b.UI.WebControl s.Button670
DataList1:_ctl0 :_ctl8System.We b.UI.LiteralCon trol130
DataList1:_ctl0 :_ctl1System.We b.UI.WebControl s.Button670
DataList1:_ctl0 :_ctl9System.We b.UI.LiteralCon trol1220
DataList1:_ctl0 :DataGrid1Syste m.Web.UI.WebCon trols.DataGrid0 136
DataList1:_ctl0 :_ctl10System.W eb.UI.LiteralCo ntrol600
DataList1:_ctl1 System.Web.UI.W ebControls.Data ListItem400
*************** *************** *************** *************** *************** *
*************

This does not show up on the first page (as we are not in edit mode yet),
but I am getting the error before the first page is executed. We do not go
into this subroutine except during editing mode - when the object would
exist.

Why would I get the error at this time and how do I get around this?

Thanks

Tom
Nov 19 '05 #2
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:eT******** ******@tk2msftn gp13.phx.gbl...
Tom,
It's hard to be sure without more context, but it seems pretty clear that
infact txtQuestion DOES NOT exist. What does exist is
DataList1:_ctl0 :txtQuestion which is quite different. If you want to get
a
reference to txtQuestion, you need to do a FindControl("tx tQuestion")
within the edit template.

In other words, what you see as txtQuestion is a control embedded within
other controls (from what you've shown, that's a datalist containing an
editTemplate which contains a textbox). It therefore isnt simply
available
as "txtQuestio n". It only exists as "txtQuestio n" as far as the edit
template is concerned. So to get it, you need to do:

private Sub Edit_Command(se nder As Object, e As DataListCommand EventArgs)
...
dim txt as TextBox = ctype(e.Item.Fi ndControl("txtQ uestion"), TextBox)
...
end sub
That was it.

I keep forgetting that I need to get the control before I can use it.

Thanks,

Tom
Karl

P.S. - Option Strict is your friend in VB.Net
--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <ts**********@f tsolutions.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
I am getting an error on a object name that doesn't exist (according to
asp.net), but if you look at the trace, it does.

Here is the error:

*************** *************** *************** *************** *************** *
***************
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error
details and modify your source code appropriately.

Compiler Error Message: BC30451: Name 'txtQuestion' is not declared.

Source Error:

Line 102: Dim positionID as Integer = Session("Positi onID")
Line 103:
Line 104:trace.warn( "txtQuestio n = " & txtQuestion.tex t)
*************** *************** *************** *************** *************** *
***************

Here is the asp code showing it as part of the EditItemTemplat e - so of
course it doesn't exist when the page is first displayed(last line shows
it):
*************** *************** *************** *************** *************** *
**************
<EditItemTempla te>
<table border="1" width="100%" CellPadding="0" CellSpacing="0"
style="margin:0 ">
<tr>
<td>
<asp:ImageButto n ID="ExpandButto n" runat="server" Font-Size="2"
ImageUrl="../images/expand.gif" Width="16" Height="16"
CommandName="Se lect"
AlternateText=" Click here to see details"></asp:ImageButton >
</td>
<td>
<asp:ImageButto n ID="CollapseBut ton" visible="false"
runat="server" Font-Size="2" ImageUrl="../images/collapse.gif" Width="16"
Height="16" CommandName="Se lect" AlternateText=" Click here to see
details"></asp:ImageButton >
<asp:label id="PositionID " Visible="false" runat="server"
Text='<%# DataBinder.Eval (Container.Data Item, "PositionID ") %>' />
<asp:label id="QuestionUni que" Visible="false" runat="server"
Text='<%# DataBinder.Eval (Container.Data Item, "QuestionUnique ") %>' />
</td>
<td width="100%">

<asp:TextBox id="txtQuestion " columns="60" MaxLength="50"
runat="server" Text='<%# DataBinder.Eval (Container.Data Item, "Question")
%>'
/>
*************** *************** *************** *************** *************** *
***************

Here is the trace.route showing it (I had to comment out the trace.warn
statement to get it):

*************** *************** *************** *************** *************** *
***********
DataList1System .Web.UI.WebCont rols.DataList52 83100
DataList1:_ctl0 System.Web.UI.W ebControls.Data ListItem9860
DataList1:_ctl0 :_ctl2System.We b.UI.LiteralCon trol1340
DataList1:_ctl0 :ExpandButtonSy stem.Web.UI.Web Controls.ImageB utton1620
DataList1:_ctl0 :_ctl3System.We b.UI.LiteralCon trol460
DataList1:_ctl0 :CollapseButton System.Web.UI.W ebControls.Imag eButton00
DataList1:_ctl0 :_ctl4System.We b.UI.LiteralCon trol130
DataList1:_ctl0 :PositionIDSyst em.Web.UI.WebCo ntrols.Label032
DataList1:_ctl0 :_ctl5System.We b.UI.LiteralCon trol130
DataList1:_ctl0 :QuestionUnique System.Web.UI.W ebControls.Labe l028
DataList1:_ctl0 :_ctl6System.We b.UI.LiteralCon trol590
---> DataList1:_ctl0 :txtQuestion
System.Web.UI.W ebControls.Text Box1650
DataList1:_ctl0 :_ctl7System.We b.UI.LiteralCon trol650
DataList1:_ctl0 :_ctl0System.We b.UI.WebControl s.Button670
DataList1:_ctl0 :_ctl8System.We b.UI.LiteralCon trol130
DataList1:_ctl0 :_ctl1System.We b.UI.WebControl s.Button670
DataList1:_ctl0 :_ctl9System.We b.UI.LiteralCon trol1220
DataList1:_ctl0 :DataGrid1Syste m.Web.UI.WebCon trols.DataGrid0 136
DataList1:_ctl0 :_ctl10System.W eb.UI.LiteralCo ntrol600
DataList1:_ctl1 System.Web.UI.W ebControls.Data ListItem400
*************** *************** *************** *************** *************** *
*************

This does not show up on the first page (as we are not in edit mode yet),
but I am getting the error before the first page is executed. We do not
go
into this subroutine except during editing mode - when the object would
exist.

Why would I get the error at this time and how do I get around this?

Thanks

Tom

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4237
by: Bryan Rasmussen | last post by:
Hi I have a little program that is importing from os.path import exists, join, isdir, normpath, isfile at one point in my program I check if a file exists using if exists("c:\projects"): and that works fine. If I change it to be if exists(thepath):
2
11849
by: Jonathan | last post by:
I am looking for a simple way to check if a database table exists. I keep getting advice to use "Try.. Catch" and other error handling methods, but I obviously don't want to have to display an error message and stop the process every time someone loads the script after the table is created because that would mean the page could only ever run...
5
32219
by: Subrahmanyam Arya | last post by:
Dear oracle gurus, I am unable to get past the error ORA-12154: TNS: could not resolve service name on my host when using hsodbc to talk to a remote mysql database. i got from the meta link all the needed documenatation to configure inithsodbc.ora,listener.ora,tnsnames.ora and related errors Here is what it says ORA-12154: SQL> select *...
7
1924
by: mcdonamw | last post by:
This may sound like a stupid stupid question and I figure it would b more "general" than pertaining to a specific Language. I'm using vb.net and I have a bunch of Const values in my program. can use them obviously by placing their names in place of values, henc the ideal behind using Const. My question is... is there a way to get the...
6
5955
by: DMUM via AccessMonster.com | last post by:
Hello I am trying to pass the name of my subform to a function/sub but I can't seem to get it to work. I am using an autokey function (ctrl E) to unlock text boxes on a subform. I have a few forms in the database that will use this function, so I need to be able to tell the code which form to unlock. What I have is as follows: Public...
6
4254
by: William | last post by:
for example, I have a global object: extern Object myobj; Can gcc get this object by using string "myobj" at runtime?? I know C++ rtti doesnt support this, but I dont know if gcc can , thanks in advance.
0
2360
by: Narendra Gc | last post by:
Hi... I am looking after a lan . I am i am not able to access one particular system , by another one particular system. But from these computers i can access all other systems in my lan and vice- versa.only the communication between these two computers is affected. Error is " A duplicate name exists on the network " I searched...
9
1736
by: Meendar | last post by:
Hi, Below is my code snippet having only one form, <form> <input type ="radio" name="action" value="xyz" checked>xyz <input type ="radio" name="action" value="zyx">zyx <input type ="radio" name="action" value="yxz">yxz </form>
25
2755
by: Jeremy Banks | last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the object itself is a subprocess, not a "popen". It seems that it would be more accurate to just name the class Subprocess, can anyone explain why this...
0
7695
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6281
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.