473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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("PositionID")
Line 103:
Line 104:trace.warn("txtQuestion = " & txtQuestion.text)
************************************************** *****************************************

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

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

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

************************************************** *************************************
DataList1System.Web.UI.WebControls.DataList5283100 DataList1:_ctl0System.Web.UI.WebControls.DataListI tem9860 DataList1:_ctl0:_ctl2System.Web.UI.LiteralControl1 340 DataList1:_ctl0:ExpandButtonSystem.Web.UI.WebContr ols.ImageButton1620 DataList1:_ctl0:_ctl3System.Web.UI.LiteralControl4 60 DataList1:_ctl0:CollapseButtonSystem.Web.UI.WebCon trols.ImageButton00 DataList1:_ctl0:_ctl4System.Web.UI.LiteralControl1 30 DataList1:_ctl0:PositionIDSystem.Web.UI.WebControl s.Label032 DataList1:_ctl0:_ctl5System.Web.UI.LiteralControl1 30 DataList1:_ctl0:QuestionUniqueSystem.Web.UI.WebCon trols.Label028 DataList1:_ctl0:_ctl6System.Web.UI.LiteralControl5 90
---> DataList1:_ctl0:txtQuestion System.Web.UI.WebControls.TextBox1650 DataList1:_ctl0:_ctl7System.Web.UI.LiteralControl6 50 DataList1:_ctl0:_ctl0System.Web.UI.WebControls.But ton670 DataList1:_ctl0:_ctl8System.Web.UI.LiteralControl1 30 DataList1:_ctl0:_ctl1System.Web.UI.WebControls.But ton670 DataList1:_ctl0:_ctl9System.Web.UI.LiteralControl1 220 DataList1:_ctl0:DataGrid1System.Web.UI.WebControls .DataGrid0136 DataList1:_ctl0:_ctl10System.Web.UI.LiteralControl 600 DataList1:_ctl1System.Web.UI.WebControls.DataListI tem400 ************************************************** ***************************************

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 1596
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("txtQuestion")
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 "txtQuestion". It only exists as "txtQuestion" as far as the edit
template is concerned. So to get it, you need to do:

private Sub Edit_Command(sender As Object, e As DataListCommandEventArgs)
...
dim txt as TextBox = ctype(e.Item.FindControl("txtQuestion"), TextBox)
...
end sub

Karl

P.S. - Option Strict is your friend in VB.Net
--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP12.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("PositionID")
Line 103:
Line 104:trace.warn("txtQuestion = " & txtQuestion.text)
************************************************** **************************
***************

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

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

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

************************************************** **************************
***********
DataList1System.Web.UI.WebControls.DataList5283100
DataList1:_ctl0System.Web.UI.WebControls.DataListI tem9860
DataList1:_ctl0:_ctl2System.Web.UI.LiteralControl1 340
DataList1:_ctl0:ExpandButtonSystem.Web.UI.WebContr ols.ImageButton1620
DataList1:_ctl0:_ctl3System.Web.UI.LiteralControl4 60
DataList1:_ctl0:CollapseButtonSystem.Web.UI.WebCon trols.ImageButton00
DataList1:_ctl0:_ctl4System.Web.UI.LiteralControl1 30
DataList1:_ctl0:PositionIDSystem.Web.UI.WebControl s.Label032
DataList1:_ctl0:_ctl5System.Web.UI.LiteralControl1 30
DataList1:_ctl0:QuestionUniqueSystem.Web.UI.WebCon trols.Label028
DataList1:_ctl0:_ctl6System.Web.UI.LiteralControl5 90
---> DataList1:_ctl0:txtQuestion
System.Web.UI.WebControls.TextBox1650
DataList1:_ctl0:_ctl7System.Web.UI.LiteralControl6 50
DataList1:_ctl0:_ctl0System.Web.UI.WebControls.But ton670
DataList1:_ctl0:_ctl8System.Web.UI.LiteralControl1 30
DataList1:_ctl0:_ctl1System.Web.UI.WebControls.But ton670
DataList1:_ctl0:_ctl9System.Web.UI.LiteralControl1 220
DataList1:_ctl0:DataGrid1System.Web.UI.WebControls .DataGrid0136
DataList1:_ctl0:_ctl10System.Web.UI.LiteralControl 600
DataList1:_ctl1System.Web.UI.WebControls.DataListI tem400
************************************************** **************************
*************

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**************@tk2msftngp13.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("txtQuestion")
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 "txtQuestion". It only exists as "txtQuestion" as far as the edit
template is concerned. So to get it, you need to do:

private Sub Edit_Command(sender As Object, e As DataListCommandEventArgs)
...
dim txt as TextBox = ctype(e.Item.FindControl("txtQuestion"), 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**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP12.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("PositionID")
Line 103:
Line 104:trace.warn("txtQuestion = " & txtQuestion.text)
************************************************** **************************
***************

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

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

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

************************************************** **************************
***********
DataList1System.Web.UI.WebControls.DataList5283100
DataList1:_ctl0System.Web.UI.WebControls.DataListI tem9860
DataList1:_ctl0:_ctl2System.Web.UI.LiteralControl1 340
DataList1:_ctl0:ExpandButtonSystem.Web.UI.WebContr ols.ImageButton1620
DataList1:_ctl0:_ctl3System.Web.UI.LiteralControl4 60
DataList1:_ctl0:CollapseButtonSystem.Web.UI.WebCon trols.ImageButton00
DataList1:_ctl0:_ctl4System.Web.UI.LiteralControl1 30
DataList1:_ctl0:PositionIDSystem.Web.UI.WebControl s.Label032
DataList1:_ctl0:_ctl5System.Web.UI.LiteralControl1 30
DataList1:_ctl0:QuestionUniqueSystem.Web.UI.WebCon trols.Label028
DataList1:_ctl0:_ctl6System.Web.UI.LiteralControl5 90
---> DataList1:_ctl0:txtQuestion
System.Web.UI.WebControls.TextBox1650
DataList1:_ctl0:_ctl7System.Web.UI.LiteralControl6 50
DataList1:_ctl0:_ctl0System.Web.UI.WebControls.But ton670
DataList1:_ctl0:_ctl8System.Web.UI.LiteralControl1 30
DataList1:_ctl0:_ctl1System.Web.UI.WebControls.But ton670
DataList1:_ctl0:_ctl9System.Web.UI.LiteralControl1 220
DataList1:_ctl0:DataGrid1System.Web.UI.WebControls .DataGrid0136
DataList1:_ctl0:_ctl10System.Web.UI.LiteralControl 600
DataList1:_ctl1System.Web.UI.WebControls.DataListI tem400
************************************************** **************************
*************

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
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...
2
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...
5
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...
7
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...
6
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...
6
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 , ...
0
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...
9
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"...
25
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
Oralloy
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 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.