2.0 Processiing Model Seriously Flawed?

C

clintonG

Simply a postulation but consider the following...

// breaks when declared in content page that uses a MasterPage
<img src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif" />

// must run as a web server control
<img src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif"
runat="server" />

However... When we want to change themes dynamically how do we modify the
value of the path for the src attribute at runtime? In ASP we used
Response.Write code blocks <%= %> the .NET equivalent of which are not
allowed in web server control declarations hence the postulation as we are
apparently missing the functional construct.

What I thought I need is the following in my HTML...

<img src="App_Themes/<%= Request.Cookies["themeName"].Value; %>/Images/<%=
Request.Cookies["themePrefix"].Value; %>METRO184x26.gif" />
runat="server" />

I've tried different quoting types but I'm not getting it right.
I've tried a binding syntax <%# %> and am not getting it right.

Surely this is me as I can't imagine the design of 2.0 is this seriously
flawed that the entire img element would have to be built in code when using
MasterPages that require dynamic Theme selections.

<%= Clinton Gallagher
 
C

clintonG

Excuse me but one of my statements needs to be corrected.

Wrong:
// breaks when declared in content page that uses a MasterPage

Right:
// breaks content page display when declared in the MasterPage

<%= Clinton Gallagher
 
L

Lau Lei Cheong

Hello,

Try give your image control an Id then use it to change the src in the
code.

Now suppose you want to change an image:
In HTML:
<img id="img_1"
src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif" runat="server"/>

At codebehind:
img_1.Src = "App_Themes/" & Request.Cookies["themeName"].Value &
"/Images/" & _
Request.Cookies["themePrefix"].Value & "METRO184x26.gif"

Since .NET framework is Object-Oriented in nature, for good coding style
use <%= %> as few as possible.

Regards,
Lau Lei Cheong
 
C

clintonG

Thanks for responding. I knew I could change the src attributes in code but
I'm still not ready to give up on what is supposed to be the new declarative
model. For example, I just looked up the new expression syntax [1].

That may allow me to use <%$ expression %> for the purpose I am interested
in but I don't understand how it can be used yet because I am still getting
server control not well formed errors...

<%= Clinton Gallagher

[1]
http://beta.asp.net/QUICKSTARTV20/aspnet/doc/pages/syntax.aspx#expressions


Lau Lei Cheong said:
Hello,

Try give your image control an Id then use it to change the src in the
code.

Now suppose you want to change an image:
In HTML:
<img id="img_1"
src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif"
runat="server"/>

At codebehind:
img_1.Src = "App_Themes/" & Request.Cookies["themeName"].Value &
"/Images/" & _
Request.Cookies["themePrefix"].Value & "METRO184x26.gif"

Since .NET framework is Object-Oriented in nature, for good coding
style use <%= %> as few as possible.

Regards,
Lau Lei Cheong

clintonG said:
Simply a postulation but consider the following...

// breaks when declared in content page that uses a MasterPage
<img src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif" />

// must run as a web server control
<img src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif"
runat="server" />

However... When we want to change themes dynamically how do we modify the
value of the path for the src attribute at runtime? In ASP we used
Response.Write code blocks <%= %> the .NET equivalent of which are not
allowed in web server control declarations hence the postulation as we
are apparently missing the functional construct.

What I thought I need is the following in my HTML...

<img src="App_Themes/<%= Request.Cookies["themeName"].Value;
%>/Images/<%= Request.Cookies["themePrefix"].Value; %>METRO184x26.gif" />
runat="server" />

I've tried different quoting types but I'm not getting it right.
I've tried a binding syntax <%# %> and am not getting it right.

Surely this is me as I can't imagine the design of 2.0 is this seriously
flawed that the entire img element would have to be built in code when
using MasterPages that require dynamic Theme selections.

<%= Clinton Gallagher
 
L

Lau Lei Cheong

Clinton,

I see your point, yet I my brain still find it difficult to debug in
some case. (e.g.: one of my site keep getting viewstate related exceptions
on clients running IE5 in MacPPC, and still can't figure out why.) :)

Back to the question, I think you may try to add Id to the webcontrol as
it's anyway essential for further control of the object in server-side. And
I suggest you check the Request.Cookies["themeName"].Value and
Request.Cookies["themePrefix"].Value is initialized when the page is
rendering. I have no idea how .NET will deal with it if .NET see it's a
"nothing" value.

Regards,
Lau Lei Cheong

clintonG said:
Thanks for responding. I knew I could change the src attributes in code
but I'm still not ready to give up on what is supposed to be the new
declarative model. For example, I just looked up the new expression syntax
[1].

That may allow me to use <%$ expression %> for the purpose I am
interested in but I don't understand how it can be used yet because I am
still getting server control not well formed errors...

<%= Clinton Gallagher

[1]
http://beta.asp.net/QUICKSTARTV20/aspnet/doc/pages/syntax.aspx#expressions


Lau Lei Cheong said:
Hello,

Try give your image control an Id then use it to change the src in the
code.

Now suppose you want to change an image:
In HTML:
<img id="img_1"
src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif"
runat="server"/>

At codebehind:
img_1.Src = "App_Themes/" & Request.Cookies["themeName"].Value &
"/Images/" & _
Request.Cookies["themePrefix"].Value & "METRO184x26.gif"

Since .NET framework is Object-Oriented in nature, for good coding
style use <%= %> as few as possible.

Regards,
Lau Lei Cheong

clintonG said:
Simply a postulation but consider the following...

// breaks when declared in content page that uses a MasterPage
<img src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif" />

// must run as a web server control
<img src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif"
runat="server" />

However... When we want to change themes dynamically how do we modify
the value of the path for the src attribute at runtime? In ASP we used
Response.Write code blocks <%= %> the .NET equivalent of which are not
allowed in web server control declarations hence the postulation as we
are apparently missing the functional construct.

What I thought I need is the following in my HTML...

<img src="App_Themes/<%= Request.Cookies["themeName"].Value;
%>/Images/<%= Request.Cookies["themePrefix"].Value; %>METRO184x26.gif"
/>
runat="server" />

I've tried different quoting types but I'm not getting it right.
I've tried a binding syntax <%# %> and am not getting it right.

Surely this is me as I can't imagine the design of 2.0 is this seriously
flawed that the entire img element would have to be built in code when
using MasterPages that require dynamic Theme selections.

<%= Clinton Gallagher
 
J

John Rivers

Most of ASP.NET is conceptually flawed architecture and implementation.
Which is a shame because almost everything else .NET is excellent.

When I read good specifications I feel happy :)
When I saw the flawed approach to ASP.NET I felt sad :(
 
C

clintonG

We are all on a bummer ;-)

<%= Clinton Gallagher

John Rivers said:
Most of ASP.NET is conceptually flawed architecture and implementation.
Which is a shame because almost everything else .NET is excellent.

When I read good specifications I feel happy :)
When I saw the flawed approach to ASP.NET I felt sad :(

Simply a postulation but consider the following...

// breaks when declared in content page that uses a MasterPage
<img src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif" />

// must run as a web server control
<img src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif"
runat="server" />

However... When we want to change themes dynamically how do we modify the
value of the path for the src attribute at runtime? In ASP we used
Response.Write code blocks <%= %> the .NET equivalent of which are not
allowed in web server control declarations hence the postulation as we
are
apparently missing the functional construct.

What I thought I need is the following in my HTML...

<img src="App_Themes/<%= Request.Cookies["themeName"].Value;
%>/Images/<%=
Request.Cookies["themePrefix"].Value; %>METRO184x26.gif" />
runat="server" />

I've tried different quoting types but I'm not getting it right.
I've tried a binding syntax <%# %> and am not getting it right.

Surely this is me as I can't imagine the design of 2.0 is this seriously
flawed that the entire img element would have to be built in code when
using
MasterPages that require dynamic Theme selections.

<%= Clinton Gallagher
 
C

clintonG

When the HTML img control has no id defined the compiler or the designer
(who knows which one) creates an id and modifies the HTML naming the
id="image1" for example (as I recall).

I understand I need to id my controls if I intend to get or set properties
in code. Many times the same image needs to be used more than once in the
same page. That will require writing code that creatres a control hierarchy
for a given control type and all of the code required to manage that
process. I have other plans for the rest of my life.

<%= Clinton Gallagher



Lau Lei Cheong said:
Clinton,

I see your point, yet I my brain still find it difficult to debug in
some case. (e.g.: one of my site keep getting viewstate related exceptions
on clients running IE5 in MacPPC, and still can't figure out why.) :)

Back to the question, I think you may try to add Id to the webcontrol
as it's anyway essential for further control of the object in server-side.
And I suggest you check the Request.Cookies["themeName"].Value and
Request.Cookies["themePrefix"].Value is initialized when the page is
rendering. I have no idea how .NET will deal with it if .NET see it's a
"nothing" value.

Regards,
Lau Lei Cheong

clintonG said:
Thanks for responding. I knew I could change the src attributes in code
but I'm still not ready to give up on what is supposed to be the new
declarative model. For example, I just looked up the new expression
syntax [1].

That may allow me to use <%$ expression %> for the purpose I am
interested in but I don't understand how it can be used yet because I am
still getting server control not well formed errors...

<%= Clinton Gallagher

[1]
http://beta.asp.net/QUICKSTARTV20/aspnet/doc/pages/syntax.aspx#expressions


Lau Lei Cheong said:
Hello,

Try give your image control an Id then use it to change the src in
the code.

Now suppose you want to change an image:
In HTML:
<img id="img_1"
src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif"
runat="server"/>

At codebehind:
img_1.Src = "App_Themes/" & Request.Cookies["themeName"].Value &
"/Images/" & _
Request.Cookies["themePrefix"].Value & "METRO184x26.gif"

Since .NET framework is Object-Oriented in nature, for good coding
style use <%= %> as few as possible.

Regards,
Lau Lei Cheong

"clintonG" <[email protected]>
¼¶¼g©ó¶l¥ó·s»D:[email protected]...
Simply a postulation but consider the following...

// breaks when declared in content page that uses a MasterPage
<img src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif" />

// must run as a web server control
<img src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif"
runat="server" />

However... When we want to change themes dynamically how do we modify
the value of the path for the src attribute at runtime? In ASP we used
Response.Write code blocks <%= %> the .NET equivalent of which are not
allowed in web server control declarations hence the postulation as we
are apparently missing the functional construct.

What I thought I need is the following in my HTML...

<img src="App_Themes/<%= Request.Cookies["themeName"].Value;
%>/Images/<%= Request.Cookies["themePrefix"].Value; %>METRO184x26.gif"
/>
runat="server" />

I've tried different quoting types but I'm not getting it right.
I've tried a binding syntax <%# %> and am not getting it right.

Surely this is me as I can't imagine the design of 2.0 is this
seriously flawed that the entire img element would have to be built in
code when using MasterPages that require dynamic Theme selections.

<%= Clinton Gallagher
 
S

Scott Allen

What I would do is get rid of the hard coded src and use the SkinID
feature, e.g, use the following in ASPX:

<asp:Image ID="Image1" runat="server" SkinID="metroimage"/>

and use the following in a skin file for each theme:

<asp:image runat="server"
Imageurl="Images/smoke_METRO184x26.gif"
skinid="metroimage" />


The theming and skinning infrastructure takes care of all the details
for you.

Themes In ASP.NET 2.0
http://odetocode.com/Articles/423.aspx
 
C

clintonG

You were correct Scott and I've reverted to the use of server controls and
SkinID as a tactic for managing images used in Themes.

<%= Clinton Gallagher


Scott Allen said:
What I would do is get rid of the hard coded src and use the SkinID
feature, e.g, use the following in ASPX:

<asp:Image ID="Image1" runat="server" SkinID="metroimage"/>

and use the following in a skin file for each theme:

<asp:image runat="server"
Imageurl="Images/smoke_METRO184x26.gif"
skinid="metroimage" />


The theming and skinning infrastructure takes care of all the details
for you.

Themes In ASP.NET 2.0
http://odetocode.com/Articles/423.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/


Simply a postulation but consider the following...

// breaks when declared in content page that uses a MasterPage
<img src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif" />

// must run as a web server control
<img src="App_Themes/SmokeAndGlass/Images/smoke_METRO184x26.gif"
runat="server" />

However... When we want to change themes dynamically how do we modify the
value of the path for the src attribute at runtime? In ASP we used
Response.Write code blocks <%= %> the .NET equivalent of which are not
allowed in web server control declarations hence the postulation as we are
apparently missing the functional construct.

What I thought I need is the following in my HTML...

<img src="App_Themes/<%= Request.Cookies["themeName"].Value; %>/Images/<%=
Request.Cookies["themePrefix"].Value; %>METRO184x26.gif" />
runat="server" />

I've tried different quoting types but I'm not getting it right.
I've tried a binding syntax <%# %> and am not getting it right.

Surely this is me as I can't imagine the design of 2.0 is this seriously
flawed that the entire img element would have to be built in code when
using
MasterPages that require dynamic Theme selections.

<%= Clinton Gallagher
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top