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

x
?
Solved

ASP.Net: Please leave my field names alone

Posted on 2006-11-14
6
Medium Priority
?
597 Views
Last Modified: 2012-05-05
I have a hidden field in my code... One in is an html input field and the other is an asp:hiddenfield object...

Both of them, when I wrote my page, had nice names... When I view the source, ASP.Net has "nicely" changed these names to...

"ctl00$ContentPlaceHolder1$InputCategoryName"

and such like.

How do I get it to leave my code alone?
0
Comment
Question by:Tentux
[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
6 Comments
 
LVL 6

Accepted Solution

by:
DonKyles earned 1000 total points
ID: 17949973
I think you are using MasterPage in this application.
"ctl00$ContentPlaceHolder1$InputCategoryName" is the name of that field show on client side.
If you want to use client side script (such as Javascript), you have to use that long name to run the script, for example document.form1.ctl00$ContentPlaceHolder1$InputCategoryName.value

Then only way to get rid of this stupid name is take out the MasterPage.
0
 
LVL 5

Assisted Solution

by:kumar_jac
kumar_jac earned 1000 total points
ID: 17955010

Hi,
 If you put it under the container it will change the name. To get that client name of the fields

use the control.ClientID in server side and pass the value to client side and use it in client side

Example

Page1.aspx.cs

btnSubmit.Attributes.Add("onlcik", "Javascript:fnShow(' " + txtName.ClientId + "');" );

in

Page.aspx

Js function

function fnShow(id)
{

        alert(document.getElementById(id).value); //use like this.
}


regards,

Krishna kumar.M
0
 
LVL 6

Expert Comment

by:DonKyles
ID: 17958966
Another way is using header and footer instead of MasterPage.
0
 

Author Comment

by:Tentux
ID: 18323447
Wouldn't have accepted the "Solution" personally. Thanks for forcing it upon me, now I know what I need to do. :P
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Six Sigma Control Plans

604 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