Aan
Aan

Reputation: 12890

Select control element in Visual Studio in ASP.NET

I am new in ASP.NET, and I have a website which I opened it by MS Visual 2010. The problem is when I try to select a control element I can not because it seems behind ContentPlaceHolder. See the image below, what can I do!

enter image description here

Here is the code of the page:

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<title>Job Seekers : Search Job in Oman</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

    <asp:Table runat="server" Width="800" style="direction: ltr" Visible="False">
    <asp:TableRow VerticalAlign="Top">

        <asp:TableCell ID="cell_register" runat="server"></asp:TableCell>
        <asp:TableCell RowSpan="2" VerticalAlign="Top" ColumnSpan="2" CssClass="tdcloud2">            
        <h2>Last News</h2>
        <div id="news" runat="server"></div>
 </asp:TableCell>
         <asp:TableCell RowSpan="2" VerticalAlign="Top" Width="200" CssClass="tdcloud">
            <h2>Site Services</h2>

            <hr /><br />
            <img src="Images/bullet.png" />  <a href="AvailableJobs.aspx">Available Jobs</a><br />
            <img src="Images/bullet.png" />  <a href="CompaniesProfiles.aspx">Compnaies Profiles</a><br />
            <img src="Images/bullet.png" />  <a href="AddCompany.aspx">Register Company</a>
         </asp:TableCell>

    </asp:TableRow>

    <asp:TableRow VerticalAlign="Top">
            <asp:TableCell ID="cell_login" runat="server" Width="200" CssClass="tdcloud">
            <h2>Login</h2>
            <hr />
            <asp:Label ID="lbl_error" runat="server" Text="" CssClass="error"></asp:Label>
            <br />
            <asp:Label ID="lbl_email" runat="server" Text="Email:" CssClass="label"></asp:Label>
            <asp:TextBox ID="txt_email" runat="server" CssClass="input"></asp:TextBox>
            <br />
            <asp:Label ID="lbl_password" runat="server" Text="Password:" CssClass="label" ></asp:Label>
            <asp:TextBox ID="txt_password" runat="server" TextMode="Password" CssClass="input"></asp:TextBox>
            <br />
            <asp:CheckBox ID="chk_company" runat="server" /><asp:Label ID="lbl_company" runat="server" Text="Company" CssClass="" ></asp:Label>
            <br /><asp:Button ID="btn_login" runat="server" Text="Login" 
        onclick="btn_login_Click" />
        <br /><br />
            <a href="Forget.aspx">Forget Password ?</a>
            <br />
            <a href="Register.aspx">Regsiter</a>
            <hr />
        </asp:TableCell>

        <asp:TableCell ID="cell_logged" runat="server" Visible="false" CssClass="tdcloud">
            <h2>Account</h2>
            <hr />
            <img src="Images/users.png" />
            <div><span class="bold"><%=Session["email"] %><%=Session["company"] %></span> </div>
            <br />
            <%
                if (Session["company"] != null)
                {
                    %>
                    <div><a href="CompInfo.aspx">Company Information</a></div>
                    <div><a href="SeekersApplications.aspx">Seekers Applications</a></div>
                    <div><a href="ChangePasswordCompany.aspx">Change Password</a></div>
                    <div><a href="AddJob.aspx">Add Job</a></div>

                        <%
                }
                else
                {
                    %>
                                <div><a href="PersInfo.aspx">Personal Information</a></div>
                    <div><a href="JobApplications.aspx">Job Applications</a></div>
                    <div><a href="ChangePasswordSeeker.aspx">Change Password</a></div>
                        <div><a href="UploadCv.aspx">Upload CV</a></div>
                    <%
                }
            %>

            <br />
            <asp:Button ID="btn_SinOut" runat="server" Text="Sign Out" 
        onclick="btn_SinOut_Click" />
        <asp:Label runat="server" Text="Are you sure you want to sign out?" id="lbl_note" Visible="false"></asp:Label>
        <asp:Button ID="btn_yes" runat="server" Text="yes" 
        onclick="yes" Visible="false" />
        <asp:Button ID="btn_no" runat="server" Text="no" 
        onclick="no" Visible="false" />
        <hr />
        </asp:TableCell>    </asp:TableRow>
    <asp:TableRow VerticalAlign="Top">

        <asp:TableCell><h2>Advertisements</h2><a href="http://nawras.om"><img src="Images/nawras.jpg" width="80" height="80" /></a>  <a href="http://www.oxy.com"><img src="Images/oxy.jpg" width="80" height="80" /></a>  <a href="http://www.pdo.co.om/"><img src="Images/pdo.gif" width="80" height="80" /></a></asp:TableCell>
        <asp:TableCell><center><h2>New Jobs</h2></center>
        <div id="jobs" runat="server"></div>
        </asp:TableCell>
        <asp:TableCell><center><h2>Jobs ends soon</h2></center><div id="jobsends" runat="server"></div></asp:TableCell>
        <asp:TableCell><center><h2>Contact</h2></center><center><a href="Contact.aspx"><img title="Contact Me" width="150" src="Images/contact.jpg" /></a></center></asp:TableCell>

    </asp:TableRow>


    </asp:Table>
    </asp:Content>

Upvotes: 0

Views: 1972

Answers (4)

christine
christine

Reputation: 51

Dim btn as Button 
btn=Me.Master.FindControl("ContentPlaceHolder1").FindControl("btn_login"))

Upvotes: 0

chavanNil
chavanNil

Reputation: 169

Just simple solution - > cut control from table cell and paste outside table. - > perform your action what you want -> then again cut the control and paste again in the previous cell.

It will work.

Upvotes: 0

Mazdak Shojaie
Mazdak Shojaie

Reputation: 1698

If you want to select a control and could not choose that control from your designer control holder,in design mode, click F4 and on the top of Properties box, you can find a list of all controls in your form/page, as listed into a listbox. But if you want to select a part of control, ex: login button of a login control, over the mouse on the control, and click control task (a little > sign) and click Convert to Template,this action explodes the control and you can select each part of it, as you want.

Upvotes: 1

Narendra
Narendra

Reputation: 3117

I think you are having a master page and trying to access the master page's control from content page. If this is the case then, go to master page and access the control there. Otherwise look for the control in source view instead of design view.

Upvotes: 0

Related Questions