|
 |
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1).
** Please don't post code questions here **
For issues specific to a particular language in .NET, please see the other forum categories. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
 |
|
|
 |
|

August 11th, 2004, 10:02 AM
|
Authorized User
|
|
Join Date: Jun 2003
Location: , Quebec, Canada.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Losing style property
In my page, I have a div that look like this.
Code:
<div id="divTest" style="<% = GetStyle %>">
All is well as long a I don't use the design view. But I make a change in design view, my div get like this
I lose the style tag. Why do I keep losing the style tag each time a make a change in design view? And why it doesn't do it when I use this
Code:
<img src="<% = GetDistributor() %>/images/<% = GetLanguage() %>/LogoMain.gif">
Stéphane
__________________
Stéphane
A programmer is a device that transform coffee in code lines
\"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.\" Rich Cook
|

August 11th, 2004, 12:10 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Hey,
VS.NET 2003 has a habit of reformatting your code everytime you switch between views. It does that automatically. The nice thing is in 2005 it's not supposed to do that.
My guess is because you have static text in the image link that it doesn't remove it. Try this:
<div id="divTest" style="<% = GetStyle %>;">
Again, strictly a guess.
Brian
|

August 11th, 2004, 12:17 PM
|
Authorized User
|
|
Join Date: Jun 2003
Location: , Quebec, Canada.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I tryed it with
Code:
<div id="divTest" style="<% = GetStyle %>;">
but I got
Code:
<div id="divTest" style="GetStyle: ">
Well look like I'll have to wait for VS.NET 2005
Stéphane
|

August 11th, 2004, 01:22 PM
|
 |
Friend of Wrox
Points: 16,481, Level: 55 |
|
|
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Stéphane,
You are missing an important point of ASP.NET programming. You need to get away from the code-embedded-in-html ways of classic ASP. It's particularly applicable to your image. If you need a programmatically modifiable image tag, use the asp:image control and runtime code to change its image url:
<asp:image id="imgLogo" runat="server" />
Runtime code (perhaps in page_load):
imgLogo.ImageUrl = String.Format("{0}/images/{1}/LogoMain.gif", GetDistributor(), GetLanguage())
This makes all parts of the code much more readable and follows the proper programming model of web forms.
You can do the same thing with your div tag. However, because there is no div server control in .NET, the control will be an HtmlGenericControl:
<div id="divTest" runat="server">
Runtime code:
divTest.Attributes.Item("style") = GetStyle
If you follow these guidelines, you shouldn't experience VS.NET interfering with your markup and you'll have much better luck overall when dealing with web forms.
Peter
-------------------------
Work smarter, not harder
|

August 11th, 2004, 01:53 PM
|
Authorized User
|
|
Join Date: Jun 2003
Location: , Quebec, Canada.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Peter
Our product must be white label. We have decide to keep using the old way for the control that are use for the label. We don't want those control to be run at the server because they will use memory for nothing.
Stéphane
|

August 11th, 2004, 02:19 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Hey,
<%= GetStyle %> is still run at the server. Peter's way of doing it adds the style attribute with no more processing efforts than <% %> way of doing it.
Brian
|

August 11th, 2004, 03:16 PM
|
 |
Wrox Author
Points: 72,055, Level: 100 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
|
|
And not only will GetStyle run on the server, the whole div tag runs at the server.
*Everything* in your page, including whitespace, spaces etc will be seen as a server side control. You may not be able to talk to them directly if you do not define a declaration for them in the Code Behind, but they are server side controls anyway.,
Cheers,
Imar
|

August 12th, 2004, 11:04 AM
|
 |
Friend of Wrox
Points: 16,481, Level: 55 |
|
|
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
And to harp on the subject...
Improper use of inline <% %> is actually MORE resource intensive then using the predesigned object model and server code methods supported by .NET.
|

August 12th, 2004, 11:05 AM
|
 |
Friend of Wrox
Points: 16,481, Level: 55 |
|
|
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Stéphane -
What do you mean by "white label"?
|

August 12th, 2004, 12:26 PM
|
Authorized User
|
|
Join Date: Jun 2003
Location: , Quebec, Canada.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
White label is use to descrive a program that you develop but is commercialise by a Company X using there name and mayby by your own company.
Stéphane
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |