troubleshooting Question

How can I find my input control?

Avatar of Michael Sterling
Michael SterlingFlag for United States of America asked on
ASPC#ASP.NET
23 Comments4 Solutions702 ViewsLast Modified:
I've got an input control that i'm trying to find in a ContentPlaceHolder and i'm having no luck. I'm including the markup and the code behind. Any help would be appreciated.
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:HiddenField runat="server" ID="hfAccessLevel" Value='<%# Eval("Page.AccessLevel") %>' />
    <div class="studentIdSearch">
        <div class="srchContainer">
            <fieldset>
                <h2>
                    <asp:Label runat="server" ID="lblPrompt" Text="To sign in or out, enter (or swipe) student id here:"
                        CssClass="prompt"></asp:Label>
                    <input id="txtStudentIdSearchBox" type="text" class="studentIdInput" />
                    <asp:Panel ID="pnlButton" runat="server">
                        <asp:Button ID="lnkbtnFindStudent" runat="server" Text="Find Student" CssClass="btnSearch" OnClick="lnkbtnFindStudent_Click" >
                        </asp:Button></asp:Panel>
                </h2>

.
.
.

CODE BEHIND


    protected void lnkbtnFindStudent_Click(object sender, EventArgs e)
    {
        ContentPlaceHolder cph = new ContentPlaceHolder();
        TextBox txb = new TextBox();
        StudentSignInSignOutRec ssisor = new StudentSignInSignOutRec();        

        string studentID;

        cph = (ContentPlaceHolder)FindControl("MainContent");

        if (cph != null)
            txb = (TextBox)cph.FindControl("txtStudentIdSearchBox");

        if (txb != null)
        {
            studentID = txb.Text.Trim();
            ssisor = Utility.DoesStudentExist(studentID);
            if (ssisor != null)
                Utility.SignInSignOutStudent(ssisor);
            //else show message student does not exist
        }
    }
ASKER CERTIFIED SOLUTION
Pratima Pharande

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 4 Answers and 23 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 23 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros