Solved

ASP.Net: Please leave my field names alone

Posted on 2006-11-14
6
589 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
  • 2
6 Comments
 
LVL 6

Accepted Solution

by:
DonKyles earned 250 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 250 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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 …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

13 Experts available now in Live!

Get 1:1 Help Now