?
Solved

c#, code behind with html5

Posted on 2016-09-08
2
Medium Priority
?
49 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The most up-to-date version of this article is on my Blog https://iconoun.com/blog/
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…
The viewer will learn how to dynamically set the form action using jQuery.
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)

777 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