By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,241 Members | 775 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,241 IT Pros & Developers. It's quick & easy.

Name not exists when it obviously does.

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.