Solved

c#, code behind with html5

Posted on 2016-09-08
2
33 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 51

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 51

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jQuery parseHTML 6 50
How to escape unsafe HTML tags 4 36
Make Float not to Wrap 15 39
How do I wrap text in dialog window 6 8
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…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
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…

696 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