Solved

ASP.Net: Please leave my field names alone

Posted on 2006-11-14
6
591 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 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

756 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