Solved

c#, code behind with html5

Posted on 2016-09-08
2
14 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
  • 2
2 Comments
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 500 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 49

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)

705 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

15 Experts available now in Live!

Get 1:1 Help Now