473,378 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Control ids

Hello

Is there a way to change the id of an generated html of an asp.net control?
What I mean is that, for example, if I have an textbox control and give it
an id of "txtName", the html generated is something like:
id="_ctl2_txtName".

Apparently,according to our clients "search engine expert", the google
search algorithms penalize controls that have id's begining with an
underscore ( _ ). Since our client is a big fan of doing the "google dance"
and wants his site to be as far up in the search engine as possible, I need
to know if I can change the auto generated leading underscore to something
else..

Thanks ahead of time
Steve

PS Just out of curiosity - how many of you out there have had to increase
your develoment time and actually have to come up with pain in the butt
workarounds (thus tying your hands and using all the time saving things of
asp.net) to just to try and get you .aspx html to be "google" friendly? Just
curious - because I know I have..
Nov 19 '05 #1
5 1447
As far as I know, there's no way to change the automatically generated ids,
short of explicitely assigning them. This can certainly be difficult in
some cases (such as repeaters/grids/lists) and probably almost impossible in
the case where literals (spaces/enters) are automatically converted to
controls.

For example, you can do:
private void rpt_ItemCreated(object sender,
System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
e.Item.ID = "row" + e.Item.ItemIndex;
}

in the ItemCreated event of a list/grid/repeater
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Steve Peterson" <sp*******@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hello

Is there a way to change the id of an generated html of an asp.net
control? What I mean is that, for example, if I have an textbox control
and give it an id of "txtName", the html generated is something like:
id="_ctl2_txtName".

Apparently,according to our clients "search engine expert", the google
search algorithms penalize controls that have id's begining with an
underscore ( _ ). Since our client is a big fan of doing the "google
dance" and wants his site to be as far up in the search engine as
possible, I need to know if I can change the auto generated leading
underscore to something else..

Thanks ahead of time
Steve

PS Just out of curiosity - how many of you out there have had to increase
your develoment time and actually have to come up with pain in the butt
workarounds (thus tying your hands and using all the time saving things of
asp.net) to just to try and get you .aspx html to be "google" friendly?
Just curious - because I know I have..

Nov 19 '05 #2
Steve Peterson wrote:
Is there a way to change the id of an generated html of an asp.net
control? What I mean is that, for example, if I have an textbox
control and give it an id of "txtName", the html generated is
something like: id="_ctl2_txtName".
Not as far as I know.

When I try it seems to set the id to the same as the name:
<input name="txtName" type="text" id="txtName" />&nbsp;
<input type="submit" name="btnOK" value="OK" id="btnOK" />

Not sure why yours is different
Apparently,according to our clients "search engine expert", the google
search algorithms penalize controls that have id's begining with an
underscore ( _ ).


I find that hard to believe. What is google going to index in a textbox? The
only references I can find on the web relating to Google and underscores is
that google can separate a phrase into words using hyphens but not
underscores (e.g. a file called my-file.html would be recognised as "my
file", but my_file.html wouldn't).
Nov 19 '05 #3
Thanks Leon

Well - you are correct:

<asp:TextBox id="txtName" runat="server"></asp:TextBox><br>
<asp:Button id="btnTest" runat="server" Text="Button"></asp:Button>

gives HTML:

<input name="txtName" type="text" id="txtName" /><br>
<input type="submit" name="btnTest" value="Button" id="btnTest" />

HOWEVER! If you put the same controls inside a web user control (like I'm
going) and place the web user control inside and .aspx page you get (at
least I do):

<input name="_ctl0:txtName" type="text" id="ctl0_txtName" /><br>
<input type="submit" name="_ctl0:btnTest" value="Button"
id="_ctl0_btnTest" />

The id is generated as to give it a uniqueid in the control collection...
(correct me if I'm wrong..)

As for our clients "search engine expert", I personally agree with you. I
think that the leading underscore for the id inside a well formed tag is
perfectly acceptable. I also find it hard to believe. Sigh...

Steve



"Leon Mayne [MVP]" <l.*********@uea.ac.uk> wrote in message
news:OV**************@TK2MSFTNGP12.phx.gbl...
Steve Peterson wrote:
Is there a way to change the id of an generated html of an asp.net
control? What I mean is that, for example, if I have an textbox
control and give it an id of "txtName", the html generated is
something like: id="_ctl2_txtName".


Not as far as I know.

When I try it seems to set the id to the same as the name:
<input name="txtName" type="text" id="txtName" />&nbsp;
<input type="submit" name="btnOK" value="OK" id="btnOK" />

Not sure why yours is different
Apparently,according to our clients "search engine expert", the google
search algorithms penalize controls that have id's begining with an
underscore ( _ ).


I find that hard to believe. What is google going to index in a textbox?
The only references I can find on the web relating to Google and
underscores is that google can separate a phrase into words using hyphens
but not underscores (e.g. a file called my-file.html would be recognised
as "my file", but my_file.html wouldn't).

Nov 19 '05 #4
On Mon, 27 Jun 2005 11:36:10 +0200, Steve Peterson wrote:
Hello

Is there a way to change the id of an generated html of an asp.net control?
What I mean is that, for example, if I have an textbox control and give it
an id of "txtName", the html generated is something like:
id="_ctl2_txtName".

Apparently,according to our clients "search engine expert", the google
search algorithms penalize controls that have id's begining with an
underscore ( _ ). Since our client is a big fan of doing the "google dance"
and wants his site to be as far up in the search engine as possible, I need
to know if I can change the auto generated leading underscore to something
else..

Thanks ahead of time
Steve

PS Just out of curiosity - how many of you out there have had to increase
your develoment time and actually have to come up with pain in the butt
workarounds (thus tying your hands and using all the time saving things of
asp.net) to just to try and get you .aspx html to be "google" friendly? Just
curious - because I know I have..

As to your PS, we worried a lot in the earlier times of the net (1994).
Now we don't worry, but do what is required to 'satisfy' (to fake it)
Google.
Nov 19 '05 #5
Steve Peterson wrote:
The id is generated as to give it a uniqueid in the control
collection... (correct me if I'm wrong..)
Sorry, I missed the fact you're using them in a user control. Yes, it would
be to make the instances of the control unique, and in this case I don't see
how you could control it at all, as allowing users to override the
incremental naming could cause problems.

It's a shame you can't specify a pattern for it to use as the prefix, such
as "ctlx-y" instead of "_ctlx_y".
As for our clients "search engine expert", I personally agree with
you. I think that the leading underscore for the id inside a well
formed tag is perfectly acceptable. I also find it hard to believe.
Sigh...


I just don't understand their logic. Presumably they are saying that the
problem is either:
1) Google won't index the text inside the control, or
2) Google will completely ignore the whole page if a control has an
underscore in the name

If the problem is 1, then who cares? There's presumably no extremely
important search terms inside the markup for the control? If they think the
problem is 2, then I'd have to say that's complete nonsense. I think you
should ask them to clarify their statement and send you evidence published
somewhere. They may go quiet then and the client will stop bugging you about
it!
Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bruce Rusk | last post by:
I'm using Stephen Lebans' RTF2 control in a report, and have discovered what may be a slight bug in it. I have a lot of non-Western language (Chinese) text in my RTF field, and such records get...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
5
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
4
by: gsb58 | last post by:
Hi! On a form I have a calendar. The form is rezised to 1024x768 (Don't worry - this is a training case) when loaded. Now I want to center the calendar on the form so that its edges are...
5
by: paul.hester | last post by:
Hi all, I have a custom control with an overridden Render method. Inside this method I'm rendering each control in its collection using their RenderControl method. However, I'm running into a...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.