locked
Can't access textbox and label controls since opening with visual studio 2008 RRS feed

  • Question

  • User-697484618 posted

    Hi

    I've copied some mobile webforms into my new .net 3.5 project, and can't access the textboxes, labels etc. in codebehind file anymore?

    Any idea is appreciated.

    Wednesday, February 13, 2008 6:51 AM

Answers

  • User-697484618 posted

    The problem was that the designer codefile (e.g. default.designer.cs) sometimes didn't hat the controls updated nor created

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 11, 2008 11:51 PM

All replies

  • User-442214108 posted

    what errors do you get when you build the project?

    Wednesday, February 13, 2008 9:59 AM
  • User-697484618 posted

    Thank you for asking.

    The control's not available in intellisign, error: "Error 108 The name 'txtBox' does not exist in the current context C:\X\test\Gym.aspx.cs 20 9 X
    ", here's my code:

    Gym.aspx

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Gym.aspx.cs" Inherits="mobile_Default" %>
    <%
    @ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <
    body>
    <mobile:Form ID="Form1" Runat="server">
    <mobile:TextBox Runat="server" ID="txtBox"></mobile:TextBox>
    </mobile:Form>
    </
    body>
    </
    html>

    Codebehind (Gym.aspx.cs):

    using System;

    using System.Collections;

    using System.ComponentModel;

    using System.Data;

    using System.Data.SqlClient;

    using System.Drawing;

    using System.Web;

    using System.Web.Mobile;

    using System.Web.SessionState;

    using System.Web.UI;

    using System.Web.UI.MobileControls;

    using System.Web.UI.WebControls;

    using System.Web.UI.HtmlControls;

    public partial class mobile_Default : System.Web.UI.MobileControls.MobilePage

    {

     

    protected void Page_Load(object sender, EventArgs e)

    {

    txtBox.Text = "Test"; // gives Error 108 The name 'txtBox' does not exist in the current context C:\X\test\Gym.aspx.cs 20 9 X

    }

     

    }

    Wednesday, February 13, 2008 11:04 AM
  • User-1655686159 posted

    Hi zipfeli,

    Are you using Web Application Project or Web Site project ? If first one try replacing CodeFile="Gym.aspx.cs" into CodeBehind="Gym.aspx.cs" and see if works.

    Wednesday, February 13, 2008 4:44 PM
  • User-697484618 posted

    The problem was that the designer codefile (e.g. default.designer.cs) sometimes didn't hat the controls updated nor created

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 11, 2008 11:51 PM