Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

c#, code behind with html5

Posted on 2016-09-08
2
Medium Priority
?
63 Views
Last Modified: 2016-09-09
on c# code behind, how can i get id name called 'DEP_FIRST_NAME_1'?  not value of the DEP_FIRST_NAME_1

<input runat="server" type="text" class="form-control" id="DEP_FIRST_NAME_1" name="DEP_FIRST_NAME_1" placeholder="First Name" />

Open in new window

0
Comment
Question by:ITsolutionWizard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 2000 total points
ID: 41790620
use this to referring to the control in code behind:
System.Web.UI.HtmlControls.HtmlInputText t = (System.Web.UI.HtmlControls.HtmlInputText)this.FindControl("DEP_FIRST_NAME_1");
            if (t != null)
            {
                Response.Write(t.ID + ":" + t.Value);
            }

Open in new window

to get the "ID" , you may do a loop at code behind, like:
foreach (Control c in Page.Controls)
            {
                foreach (Control childc in c.Controls)
                {
                    Response.Write(childc.ID + "<br>");
                }
            }

Open in new window

or you want to get it from jQuery?
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 41790627
for jQuery, you can try:
<script src="https://code.jquery.com/jquery-3.1.0.slim.min.js"
	    integrity="sha256-cRpWjoSOw5KcyIOaZNo4i6fZ9tKPhYYb6i5T9RSVJG8="
	    crossorigin="anonymous"></script>

<script language="javascript">
    $('#form1 input').each(function (id, value) {
        console.log(this.id);
    });
</script>

Open in new window

0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

618 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