Solved

Controls created in Source view do not show up under intellisense

Posted on 2008-06-23
5
387 Views
Last Modified: 2010-04-21
Greetings all

I have just completed the setting up of a page, done in source view, and using some CSS.

I switched to code-behind to begin with my coding but noticed that many of the controls, particualrly buttons and textboxes) were not showing up under inyellisense.

Is there perhaps something that I need to do before this will work?


In advance, thanks!

   allanmark
0
Comment
Question by:allanmark
  • 3
  • 2
5 Comments
 

Author Comment

by:allanmark
ID: 21844396
Oops ... should have attache dthe source - please see snippet.
PageFile="~/Scribble01.master" AutoEventWireup="true" CodeFile="Members.aspx.cs" Inherits="Pages_Member_Members" Title="Member Page" %>

<%@ MasterType VirtualPath="~/Scribble01.master" %>
 

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 

<div id = "membershipTop">
 

    <div id="memberLog">

    

        <center>

        <asp:LoginStatus ID="loginMember" runat="server" CssClass="loginStatus" OnLoggedOut="loginMember_LoggedOut" />       
 

        <!-- Start: Login control (converted to Template) -->    

        

       <asp:Login ID="logMember" runat="server" CssClass="login" TitleText="Membership Login"

        FailureText="Login attempt was unsuccessful."  UserNameLabelText="Member:"

        PasswordLabelText= "Password:" UserNameRequiredErrorMessage="Member is required." >

        <TitleTextStyle BackColor="CornflowerBlue" Font-Bold="True" />

     <LayoutTemplate>

         <table border="0" cellpadding="1" cellspacing="0" style="border-collapse: collapse">

             <tr>

                 <td>

                     <table border="0" cellpadding="0">

                         <tr>

                             <td align="center" colspan="2" style="font-weight: bold; background-color: cornflowerblue">

                                 Membership Login</td>

                         </tr>

                         <tr>

                             <td align="right">

                                 <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Member:</asp:Label></td>

                             <td>

                                 <asp:TextBox ID="UserName" runat="server"></asp:TextBox>

                                 <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"

                                     ErrorMessage="Member is required." ToolTip="Member is required." ValidationGroup="logDefault">*</asp:RequiredFieldValidator>

                             </td>

                         </tr>

                         <tr>

                             <td align="right">

                                 <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label></td>

                             <td>

                                 <asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>

                                 <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"

                                     ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="logDefault">*</asp:RequiredFieldValidator>

                             </td>

                         </tr>

                         <tr>

                             <td colspan="2">

                                 <asp:CheckBox ID="RememberMe" runat="server" Text="Remember me next time." />

                             </td>

                         </tr>

                         <tr>

                             <td align="center" colspan="2" style="color: red">

                                 <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>

                             </td>

                         </tr>

                         <tr>

                             <td align="right" colspan="2">

                                 <asp:Button ID="btnForgot" runat="server" Text="Forgot Password" ValidationGroup="logForgot" OnClick="btnForgot_Click" />

                                 <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="logDefault" />

                             </td>

                         </tr>

                     </table>

                 </td>

             </tr>

         </table>

     </LayoutTemplate>

    </asp:Login>

        <!-- End: Login control (converted to Template) -->    

        </center>    

    

    <!-- end <div id="memberLog"> -->    

    </div>

    

    <asp:LoginView ID="logViewTop" runat="server"  >        

    

    <AnonymousTemplate>

    <div style ="position: relative; top: opx; width: 76%;">

        <h3>Welcome to our membership page!</h3>

        <p>Please complete the membership application, below, as completely as possible, before submitting.</p>

        <p>Applications are reviewed on a weekly basis. You will be notified via email (sent to the address provided in your application - please ensure that this is correct).</p>

        <p class="smallerFontSize">Note: Membership decisions are, at all times, the prerogative of the committee, whose decision shall be final.</p>              

    </div>

    </AnonymousTemplate>

            

    <LoggedInTemplate>

    <div style ="position: relative; top: opx; width: 76%;">    

        <h3>Welcome!</h3>

        <p>As a logged in member you can use this page to:</p>

        <ul id="memberOptions" type="circle">

            <li>Change your password</li>

            <li>Change your email address</li>

        </ul>

    </div>

    </LoggedInTemplate>

    

    </asp:LoginView>

    <!-- End <LoginView id="logViewTop"> -->

     

<!-- end <div id="membershipTop"> -->        

</div>
 

    

<div id = "membershipBody">
 

     <asp:LoginView ID="logViewBody" runat="server" >

     

        <AnonymousTemplate>

        <center>

        <asp:Panel ID="pnlNonMembership" runat="server" CssClass="membershipPanel" Width="85%">

    

        <!-- Table to sort out the membership application info. -->

        <table id="membershipApp" style="position: relative" >

                <tr>            

                <!-- Row: Name -->

                <td>

	            	<asp:Label ID="lblName" runat="server" CssClass="smallerFontSize" AssociatedControlID="txtName">Name:</asp:Label>

	            </td>

                <td colspan="4">

                    <asp:TextBox ID="txtName" runat="server" Width="140px"></asp:TextBox>		

                    <asp:RequiredFieldValidator ID="rfvName" runat="server" ControlToValidate="txtName"

                        ErrorMessage="*" SetFocusOnError="True" Style="position: relative" ValidationGroup="UserApply"></asp:RequiredFieldValidator></td>            

    	    <!-- End: Row: Name -->

            </tr>

        

    	    <tr>	    

	        <!-- Row: Surname  -->

                <td>

                    <asp:Label ID="lblSurname" runat="server" CssClass="smallerFontSize" AssociatedControlID="txtSurname">Surame:</asp:Label>

                </td>

                <td colspan="4">

                <asp:TextBox ID="txtSurname" runat="server" Width="180px"></asp:TextBox>

                <asp:RequiredFieldValidator ID="rfvSurname" runat="server" ControlToValidate="txtSurname"

                        ErrorMessage="*" SetFocusOnError="True" Style="position: relative" ValidationGroup="UserApply"></asp:RequiredFieldValidator></td>            

    	    <!-- End: Row: Surname -->

            </tr>

       

            <tr>        

        	<!-- Row: Blank -->

                <td colspan="5" height="12"></td>

            </tr>

        

            <tr>                

    	    <!-- Row: DOB -->

                <td>

		            <asp:Label ID="lblDob" runat="server" CssClass="smallerFontSize" AssociatedControlID="txtDob">BirthDate:</asp:Label>

                </td>

                <td colspan="4">

	    	        <asp:TextBox ID="txtDob" runat="server" Width="120px"></asp:TextBox>

	    	        <asp:RequiredFieldValidator ID="rfvDob" runat="server" ControlToValidate="txtDob"

                        ErrorMessage="*" SetFocusOnError="True" Style="position: relative" ValidationGroup="UserApply"></asp:RequiredFieldValidator></td>            

	        <!-- End: Row: DOB -->

            </tr>
 

            <tr>                

	        <!-- Row: Blank -->

                <td colspan="5" height="12"></td>

	        </tr>
 

            <tr>        

	        <!-- Row: User1 -->

                <td>

		            <asp:Label ID="lblUser1" runat="server" CssClass="smallerFontSize" AssociatedControlID="txtUser1">Username (preferred):</asp:Label>

                </td>

                <td colspan="4">

		            <asp:TextBox ID="txtUser1" runat="server" Width="120px"></asp:TextBox>

		            <asp:RequiredFieldValidator ID="rfvUser1" runat="server" ControlToValidate="txtUser1"

                        ErrorMessage="*" SetFocusOnError="True" Style="position: relative" ValidationGroup="UserApply"></asp:RequiredFieldValidator></td>            

	        <!-- End: Row" User1 -->

            </tr>
 

            <tr>        

	        <!-- Row: User2 -->

                <td>

    		<asp:Label ID="lblUser2" runat="server" CssClass="smallerFontSize" AssociatedControlID="txtUser2">Username (alternate):</asp:Label>

                </td>

                <td colspan="4">

		            <asp:TextBox ID="txtUser2" runat="server" Width="120px"></asp:TextBox>

		            <asp:RequiredFieldValidator ID="rfvUser2" runat="server" ControlToValidate="txtUser2"

                        ErrorMessage="*" SetFocusOnError="True" Style="position: relative" ValidationGroup="UserApply"></asp:RequiredFieldValidator></td>            

	        <!-- End: Row: User2 -->

            </tr>

        

            <tr>                

	        <!-- Row: Blank  -->

                <td colspan="5" height="12"></td>

            </tr>

        

            <tr>                

	        <!-- Row: Email -->

                <td>

		            <asp:Label ID="lblEmail" runat="server" CssClass="smallerFontSize" AssociatedControlID="txtEmail">Email:</asp:Label>

                </td>

                <td colspan="4">

	    	        <asp:TextBox ID="txtEmail" runat="server" Width="200px"></asp:TextBox>

	    	        <asp:RequiredFieldValidator ID="rfvEmail" runat="server" ControlToValidate="txtEmail"

                        ErrorMessage="*" SetFocusOnError="True" Style="position: relative" ValidationGroup="UserApply"></asp:RequiredFieldValidator></td>            

    	    <!-- End: Row: Email -->

            </tr>

        

            <tr>                

	        <!-- Row: ConfirmEmail -->

                <td>

		            <asp:Label ID="lblConfEmail" runat="server" CssClass="smallerFontSize" AssociatedControlID="txtConfEmail">Confirm Email:</asp:Label>

                </td>

                <td colspan="4">

		            <asp:TextBox ID="txtConfEmail" runat="server" Width="200px"></asp:TextBox>

		            <asp:RequiredFieldValidator ID="rfvEmailConf" runat="server" ControlToValidate="txtConfEmail"

                        ErrorMessage="*" SetFocusOnError="True" Style="position: relative" ValidationGroup="UserApply"></asp:RequiredFieldValidator></td>            

    	    <!-- End: Row: ConfirmEmail -->

            </tr>

        

            <tr>                

	        <!-- Row: Blank -->

                <td colspan="5" height="12"></td>

            </tr>

        

            <tr>                

	        <!-- Row: Message -->

                <td>

    		        <asp:Label ID="lblMessage" runat="server" CssClass="smallerFontSize" AssociatedControlID="txtMessage">Message:</asp:Label>

                </td>

                <td colspan="4">

		            <asp:TextBox ID="txtMessage" runat="server" TextMode="MultiLine" Width="620px" Height="200px"></asp:TextBox>

                </td>

	        <!-- End: Row: Message -->

            </tr>
 

            <tr>                

	        <!-- Row: Blank  -->

                <td colspan="5" height="12"></td>

            </tr>

              

            <tr>                

	        <!-- Row: Sample -->

                <td>

		            <asp:Label ID="lblSample" runat="server" CssClass="smallerFontSize" AssociatedControlID="txtSample">Sample of your writing:</asp:Label>

                </td>

                <td>

	    	        <asp:TextBox ID="txtSample" runat="server" TextMode="MultiLine" Width="620px" Height="350px"></asp:TextBox>

	    	        <asp:RequiredFieldValidator ID="rfvSample" runat="server" ControlToValidate="txtSample"

                        ErrorMessage="*" SetFocusOnError="True" Style="position: relative" ValidationGroup="UserApply"></asp:RequiredFieldValidator></td>            

                <td colspan="3">

                    <center>

                    <asp:Button ID="btnUpLoad" runat="server" Text="Upload text file" Tooltip="Currently only text files accepted"/>     

                        <asp:Button ID="Button1" runat="server" Style="position: relative" Text="Button" />

                    <br/>           

                    <br/>           

                    <asp:Button ID="btnClear" runat="server" Text="Clear sample" ToolTip="Clears all text from the sample"/>                

                    </center>

                </td>            

	        <!-- End: Row: Sample -->

            </tr>              

              

            <tr>                

	        <!-- Row: Blank -->

                <td colspan="5" style="height: 10px"></td>

            </tr>

    

        <!-- End: table id="membershipApp". -->

        </table>     

    

        <asp:Button ID="btnSubmitApp" runat="server" Text="Submit Application" ValidationGroup="UserApply" Font-Bold="True" Font-Size="Larger" ForeColor="Red" />

    

        </asp:Panel>
 

     

        </center>       

        <!-- end - AnonymousTemplate for LoginView: logViewBody -->

        </AnonymousTemplate>                        

        

        <LoggedInTemplate>        
 

        <center>

        <asp:Panel ID="pnlMembership" runat="server" CssClass="membershipPanel" Width="400px">
 

        <table id="tblLoggedIn"   style="position: relative">

            <tr>

                <td style="width: 110px">

                <asp:Label ID="lblUser" runat="server" CssClass="smallerFontSize" >Username: </asp:Label>

                </td>

                <td style="width: 240px">

                <asp:Label ID="lblUsername" runat="server" CssClass="labelHighlighted"></asp:Label>

                </td>

            </tr>

            <tr>

                <td colspan="2" height="12px"></td>

            </tr>            

            <tr>

                <td style="width: 110px; height: 30px;">

                <asp:Label ID="lblPassword" runat="server" AssociatedControlId="txtPassword" CssClass="smallerFontSize" TextMode="Password">New password: </asp:Label>

                </td>

                <td style="width: 240px; height: 30px;">

                <asp:TextBox ID="txtPassword" runat="server" Width="110px" TextMode="Password"></asp:TextBox>

                </td>

            </tr>

            <tr>

                <td style="width: 110px">

                <asp:Label ID="lblPassConf" runat="server" AssociatedControlId="txtPassConfirm" CssClass="smallerFontSize">Comfirm password:</asp:Label>

                </td>

                <td style="width: 240px">

                <asp:TextBox ID="txtPassConfirm" runat="server" Width="110px" TextMode="Password"></asp:TextBox>

                </td>

            </tr>

            <tr>

                <td colspan="2" height="12px"></td>

            </tr>            

            <tr>

                <td style="width: 110px">

                <asp:Label ID="lblEmail" runat="server" AssociatedControlId="txtEmail" CssClass="smallerFontSize">Email: </asp:Label>

                </td>

                <td style="width: 240px">

                <asp:TextBox ID="txtEmail" runat="server" Width="240px"></asp:TextBox>

                </td>

            </tr>

            <tr>

                <td style="width: 110px">

                <asp:Label ID="lblConfEmail" runat="server" AssociatedControlId="lblConfEmail" CssClass="smallerFontSize">Confirm Email: </asp:Label>

                </td>

                <td style="width: 240px">

                <asp:TextBox ID="txtConfirmEmail" runat="server" Width="240px"></asp:TextBox>

                </td>

            </tr>

            <tr>

            <!-- Row: Blank -->

            <td colspan="2" style="height: 10px"></td>

            </tr>

        </table>

        

        <asp:Button ID="btnSubmitChanges" runat="server" Text="Submit Changes" Font-Bold="True" Font-Size="Larger" ForeColor="Red"  />        

        

        </asp:Panel>

        </center>

        

         <!-- end - LoggedInTemplate for LoginView: logViewBody -->

        </LoggedInTemplate>

     
 

     </asp:LoginView>

     <!-- End <LoginView id="logViewBody"> -->     

     
 
 

<!-- end <div id="membershipTop"> -->        

</div>
 

</asp:Content>

Open in new window

0
 
LVL 15

Expert Comment

by:NazoUK
ID: 21844505
I think the problem is that all your controls are inside templated controls. To access these controls from code you'd need to use the findcontrol method of the templated control they are inside, you can't access directly from your code, hence they don't show up in intellisense.

For example to access the UserName textbox inside logMember you'd write something like:

TextBox tb = (TextBox) logMember.FindControl("UserName");

The variable tb then references the textbox you want and you can access it's properties using this.
0
 

Author Comment

by:allanmark
ID: 21844551
Thanks 4 the quick response!

I suppose my  question, before I go further,  should be: is the way I have done this page Ok? Or is it bad? Do I need to redo it?

If the page passes, then I need to do a FindControl for each field, since I will be using all of them. Woudl it be acceptable to call a routine from my pageLoad (see snippet) or is teher a better way?
protected void Page_Load(object sender, EventArgs e)

{

   ...............

   CreateAccessibles()
 

}
 

protected void CreateACcessibles()

{

  TextBox tbUser = (TextBox) logMember.FindControl("UserName");

  TextBox tbName = (TextBox) logMember.FindControl("txtName");

  TextBox tbSurname = (TextBox) logMember.FindControl("txtSrname");

  ............

  .............

}

Open in new window

0
 
LVL 15

Accepted Solution

by:
NazoUK earned 250 total points
ID: 21844798
To be honest I haven't used the login controls a lot but the way you've done things seems pretty reasonable to me.

I don't see anything wrong with creating a function to do the work of assigning all your textboxes to variables. You'd need to make them global variables though, so they can be accessed inside any function. Put your variable definitions at the top of your codefile outside any method definitions (but inside the class definition):

TextBox tbUser = null;

Then inside CreateAccessibles:

tbUser = (TextBox) logMember.FindControl("UserName");
0
 

Author Closing Comment

by:allanmark
ID: 31469656
Many thanks!!!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this Micro Tutorial users will learn how to embed custom fonts into websites using @font-face in CSS Select a font: Ensure the EULA allows you to use @font-face: Download the font: Get the browser-compatible files you need: Edit your CSS       - Name …
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now