0

I've had an ongoing problem in my asp.net website, where I cannot access controls from the .cs file. It gives me the error: control not in context or whatever it normally does.

What's weird is that I have no designer.cs files or the option to convert to web application.

I've tried right clicking my project name, my file names, and everything else, but I cannot find "Convert To Web Application." I'm using Visual Studio 2013 Ultimate Edition and the latest versions of ASP.NET and stuff. For example, I have the following code in my page:

<asp:TextBox ID="AssignScreenName" runat="server" CssClass="form-control" Placeholder="Screen name"></asp:TextBox> (It's for renaming yourself on your profile)

When in the Page_Load class of my code behind, AssignScreenName.Text will give me that error. I have to use Page.FindControl("AssignScreenName"), which doesn't let me convert to text and assign it to the profile.

Is there a way around this, or a way to fix it? (If you need anymore information post it in the comments, I'll try to check back here daily)

Thanks!

Dalorzo
  • 19,834
  • 7
  • 55
  • 102
  • Have you seen this: http://stackoverflow.com/questions/19561982/visual-studio-2013-missing-convert-to-web-application ? – David Tansey Aug 11 '14 at 01:19
  • Page.FindControl("AssignScreenName") will work if you cast it to the correct type, i.e. "Page.FindControl("AssignScreenName") as TextBox" – sh1rts Aug 11 '14 at 03:48
  • Thank you, Sh1rts, that's a temporary solution. And David, I tried your solution, but "Convert To Web Application" isn't in the Project menu (Which I can only access by clicking the label that says "Solution 'ProjectName' (1 Project)". It turns into "Website" if I click anything else. – TheNationalSarcasmSociety Aug 11 '14 at 17:03

0 Answers0