Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.Net Controls adding CTxxx - makes for big code!

Status
Not open for further replies.

elhaix

Programmer
Joined
Jul 31, 2006
Messages
115
Location
CA
We have a situation where the use of ASP.Net controls is creating a bunch of extra code (no, really?)...

ie:
Code:
<div style="float: right;">               
                <label for="ctl00_ctl00_cphMain_cphMain_ucSearchFormRent_txtZip" >ZIP:</label>
                <input name="ctl00$ctl00$cphMain$cphMain$ucSearchFormRent$txtZip" type="text" maxlength="5" id="ctl00_ctl00_cphMain_cphMain_ucSearchFormRent_txtZip" tabindex="3" style="width:75px;" />
            </div>

Notice the ct100 stuff?

Using the Wizard control also renders similar results.

I'm also noticing this at the top of the page:

Code:
<head id="ctl00_ctl00_Head1"><meta http-equiv="imagetoolbar" content="no" /><meta id="ctl00_ctl00_metaKeywords" name="keywords" ... etc

From an SEO perspective all this additional ct100 is a mess. Can it all be replaced by say, "aa" = ct100 to minimize the size of the code?

Any other comments are welcome.



Thanks.


 
That's generated by ASP.NET for most controls (especially if they are child controls or part of a user control). The only way to override that would be to modify tehm before the page is rendered (i.e. with a ResponseStream) but I wouldn't recommend that as it may interfere with any server-side code that you have.

As for the SEO point, I'm not sure what problems you are referring to. As far as I know, it won't have much influence of SE's but you could always take this to the SEO forum (forum828) if you have doubts.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 

Actually, on a page where there are several controls, we replaced all the ct100_ bits of text and reduced the page size from 120k to around 30k!!!

From SEO - some engines won't look at the page if it's > 120k.

 
we replaced all the ct100_ bits of text
What method did you use to do this?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Oh, I meant simply in the code (after view source) of the page. Not in the actual functional code, that is, we looked at the 120k text file of code, and replaced the ct100_'s, which reduced the text file size to around 30k.


If there's a way to do this from an execution time perspective... that's what I'm looking for.

 
Yes, you can use the method I mentioned above, it's just that you'll have to do some testing on it first to see if it works and doesn't affect anything (which I'm extremely doubtful that it will!). Also, what happens if the control isn't prefixed with "ct100"?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 

Hmm... I have a vague idea about what you're getting at with the ResponseStream solution. Could you give me a better description/example?


Thanks!
 
Great.

I've tried the method shown at and I get the concept, but replacing .Net's control naming convention breaks the app.

ie. in the Write method

Code:
                Regex oRegEx = new Regex("ctl00", RegexOptions.IgnoreCase);
                if (oRegEx.IsMatch(szCompleteBuffer))
                {
                    //Found string, so replace all occurences with the new value (use a non-case sensitive
                    // match)
                    string newBuffer = Regex.Replace(szCompleteBuffer, "ctl00", "A_", RegexOptions.IgnoreCase);

                    //Set the reference so can use same code below...
                    szCompleteBuffer = newBuffer;
                }

I replace all instances of "ctl00" with "A_". Sure when we View Source, it's replaced, however the functionality is broken when trying clicking on the control's action items.


Any other recommendations?
 
One thing that comes to mind is this:

There are known ways to decrypt the ViewState string. Therefore, theoretically, one could decrypt the ViewState string, add this same filter to that, re-encrypt it (however, I haven’t come across a method to do this manually), and place it back in the appropriate place in the rendered code. Makes sense, right?

Somewhat convoluted, isn't it?
 
Yes, it does make sense but I think it will be a lot more trouble than it's worth. As a much simpler test, you could try removing all whitespace in your HTML (using the same method as above) and therefore condensing the actual HTML output. I don't know how much of an impact it will have on your page (unless you have a link to your site?) but you could give it a go. e.g.



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Alternatively, you could look at the architecture of your page. I've just created a simple page with quite a lot of controls and it was nowhere near 120k so maybe you could look at splitting the page out into seperate pages (or you could actually provide a sample of your page and others could suggest any alternative routes that they can think of).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Well, you're right, it's more trouble than what it's worth.

This was a problem I was asked to look into. Unfortunately, I don't have any control over the actual page, simply simulated the problem being experienced with my own page.

My recommendation is quite similar to yours - break out the functionality into multiple pages and remove the .Net controls. Most of any control's functionality can be easilly duplicated by a good coder.

I'll take a look at the whitespace filter tomorrow. Thanks for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top