10 Replies - 69892 Views - Last Post: 20 July 2010 - 05:03 AM Rate Topic: -----

#1 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

...does not exist in the current context {RESOLVED}

Posted 10 October 2008 - 09:06 PM

Has anyone ran into this before, and if so how did you resolve it. Here's the scenario, I have this code

DateTime start = Convert.ToDateTime(StartDate.Text);
DateTime end = Convert.ToDateTime(EndDate.Text);
string title = NewTitle.Text;
int active = Convert.ToInt32(rblIsActive.SelectedValue);



And I get a compilation error saying those controls don't exist :crazy: , but here they are in the ASPX page

	<td valign="top">
		<table style="width:100%;" cellpadding="3" cellspacing="0">
			<tr>
	<td style="width: 70px;">
		New Title:</td>
	<td>
		<asp:TextBox ID="NewTitle" runat="server" CssClass="reg_form" Text='<%#Eval("Title") %>' />
	</td>
</tr>
<tr>
	<td>
		Start Date:</td>
	<td>
		<asp:TextBox ID="StartDate" runat="server" CssClass="reg_form" Text='<%#Eval("StartDate") %>' />
		<a href="java script:void(0);return false;" onclick="window.open('../../Popups/PopCalendar.aspx?type=StartDate','cal','width=250,height=225, status=0,menubar=0,location=0,toolbar=0,directories=0;')">
			<img src="../../images/main_images/SmallCalendar.gif" border="0" width="16" height="16"></a>
	</td>
</tr>
<tr>
	<td>
		End Date:</td>
	<td>
		<asp:TextBox ID="EndDate" runat="server" CssClass="reg_form" Text='<%#Eval("EndDate") %>' />
		<a href="java script:void(0);return false;" onclick="window.open('../../Popups/PopCalendar.aspx?type=EndDate','cal','width=250,height=225, status=0,menubar=0,location=0,toolbar=0,directories=0;')">
			<img src="../../images/main_images/SmallCalendar.gif" border="0" width="16" height="16"></a>
	</td>
</tr>
<tr>
	<td valign="top">
		Active:</td>
	<td>
		<asp:RadioButtonList ID="rblIsActive" runat="server">
			<asp:ListItem Value="1" Selected="true" Text="Yes" />
			<asp:ListItem Value="0" Selected="false" Text="No" />
		</asp:RadioButtonList>
	</td>
</tr>



Has anyone seen this/resolved an issue like this before in ASP.NET?

Is This A Good Question/Topic? 0
  • +

Replies To: ...does not exist in the current context {RESOLVED}

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: ...does not exist in the current context {RESOLVED}

Posted 10 October 2008 - 10:45 PM

I don't see anything wrong with what you posted.

Is there anything that you didn't include that may be impacting the ability of the page to see the controls?

I typically run into this when using Ajax or having controls within another control. We use a lot of wizards which load user controls that contain all the functionality of our portal. Using the FindControl method is a necessity in these situations, as I am sure you already know. But I had to ask.

Anything like that going on with what you are doing?
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: ...does not exist in the current context {RESOLVED}

Posted 10 October 2008 - 11:22 PM

Not really, I mean these controls are inside an <asp:View control, then again all other controls are as well, and none of them have I ran into this issue before. I'm almost ready to pull my damn hair out, not that I have a lot to pull anyways!

Also, no ajax at all, just simple ,Net server controls :blink:
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: ...does not exist in the current context {RESOLVED}

Posted 11 October 2008 - 10:16 AM

Anyone have any ideas? I even went as far as to delete the page and recreate it, same thing :crazy:
Was This Post Helpful? 0
  • +
  • -

#5 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: ...does not exist in the current context {RESOLVED}

Posted 11 October 2008 - 10:42 AM

Issue's resolved. Sometimes I wonder about myself, those controls are inside a DataList so I had to use

TextBox startDate = (TextBox)EditTag_DL.FindControl("StartDate");
TextBox endDate = (TextBox)EditTag_DL.FindControl("EndDate");
TextBox newTitle = (TextBox)EditTag_DL.FindControl("NewTitle");
CheckBox keepActive = (CheckBox)EditTag_DL.FindControl("KeepActive");



Now I just need to get rid ofthe following error that happens when I click the "Update" button

Quote

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

Was This Post Helpful? 0
  • +
  • -

#6 jacobjordan  Icon User is offline

  • class Me : Perfection
  • member icon

Reputation: 113
  • View blog
  • Posts: 1,499
  • Joined: 11-June 08

Re: ...does not exist in the current context {RESOLVED}

Posted 11 October 2008 - 06:43 PM

PsychoCoder, asking a q-q-question??? I didn't think it was p-p-possib-b-ble!! Help! Water! I t-t-think i'm having a st-t-troke!!
Was This Post Helpful? 0
  • +
  • -

#7 aie.k  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-November 08

Re: ...does not exist in the current context {RESOLVED}

Posted 24 November 2008 - 02:21 AM

View PostPsychoCoder, on 11 Oct, 2008 - 09:42 AM, said:

Issue's resolved. Sometimes I wonder about myself, those controls are inside a DataList so I had to use

TextBox startDate = (TextBox)EditTag_DL.FindControl("StartDate");
TextBox endDate = (TextBox)EditTag_DL.FindControl("EndDate");
TextBox newTitle = (TextBox)EditTag_DL.FindControl("NewTitle");
CheckBox keepActive = (CheckBox)EditTag_DL.FindControl("KeepActive");



Now I just need to get rid ofthe following error that happens when I click the "Update" button

Quote

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.



Hello, stumbled upon this while trying to figure the same happening out, ie. Invalid .... Since I just registered in this forum, I cannot send you a PM and thus choosing to post here. The coding part of this feels a bit tricky and if you could give me an example on how to Register... I would much appreciate it and have a couple of hours to do some other coding :). Thank you in advance.

Edit: If that is the part to correct, found a blog that says otherwise http://dotnetscribbl...-and-event.html and it feels like I really don't know where to start. Being new here I don't want to give the impression that I want my homework done but any information pointing me in the right direction would make a big difference to my day.

This post has been edited by aie.k: 24 November 2008 - 02:34 AM

Was This Post Helpful? 0
  • +
  • -

#8 nakul_sehgal  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-June 09

Re: ...does not exist in the current context {RESOLVED}

Posted 12 June 2009 - 04:12 PM

Hey, I ran into the same problem with textbox controls, earlier they were running Ok, but when I build the application, it shows this error, that the respective textbox does now exist in the current context. I used your code and idea to overcome this problem, but still exists.

Any help would be appreciated.

Thank you
Was This Post Helpful? 0
  • +
  • -

#9 shekhar_pawar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-November 09

Re: ...does not exist in the current context {RESOLVED}

Posted 18 November 2009 - 11:51 PM

Hey Guys,
Its quite simple.
This error happens due to design bugs with Visual Studio.
Just cut and paste the controls again. It will resolve the issue.


I Did the same :P

This post has been edited by shekhar_pawar: 18 November 2009 - 11:52 PM

Was This Post Helpful? 0
  • +
  • -

#10 subiparihar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 20-July 09

Re: ...does not exist in the current context {RESOLVED}

Posted 10 December 2009 - 05:33 AM

I am also facing the same error and tried to cut and past controls but unable to compile my code. It giving control are not exist but here they are in the ASPX page. any suggestion?
Was This Post Helpful? 0
  • +
  • -

#11 Guest_Emma*


Reputation:

Re: ...does not exist in the current context {RESOLVED}

Posted 20 July 2010 - 05:03 AM

private void pi_SendEmail()
{
using (DAL.MyCarCoverDataContext dbContext = new MyCarCoverDataContext(ConfigurationManager.AppSettings["DBConnection"]))
{

BLL.Order oOrder = new BLL.Order(dbContext);
tOrder dbtOrder = OrderID;
{
string sAdminToAddress = ConfigurationManager.AppSettings["ContactFormToAddress"];
string sSendForename = dbtOrder.Forename;
string sSendSurname = dbtOrder.Surname;
string sSendOrderID = dbtOrder.ID.ToString();
string sSendEmail = dbtOrder.Email;

string sAdminFilePath = Server.MapPath("~/templates/order-confirmation-admin.txt");
string sAdminMessageBody = File.ReadAllText(sAdminFilePath);
sAdminMessageBody = sAdminMessageBody.Replace("@@OrderID@@", sSendOrderID);

string sUserFilePath = Server.MapPath("~/templates/order-confirmation-user.txt");
string sUserMessageBody = File.ReadAllText(sUserFilePath);
sUserMessageBody = sUserMessageBody.Replace("@@Forename@@", sSendForename);
sUserMessageBody = sUserMessageBody.Replace("@@Surname@@", sSendSurname);
sUserMessageBody = sUserMessageBody.Replace("@@OrderID@@", sSendOrderID);

bool bSendToAdminResult = Web.EmailSender.SendMessage(sAdminToAddress, "Order Confirmation", sAdminMessageBody);
bool bSendToUserResult = Web.EmailSender.SendMessage(sSendEmail, "Order Confirmation", sUserMessageBody);
}
}
}


I have and error saying that on line tOrder dbtOrder = OrderID, OrderID does not exist within the current context.

If i take this line out then the dbtOrder's get red underlined becasue they don't exist within the context.


Basically i want to add fields from a database (tOrder) from table (dbtOrder) into email parameters.

Help?
Was This Post Helpful? 0

Page 1 of 1