473,569 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting from asp to asp.net with c#

Ok I know a lot of asp but not a lot of asp.net and C# so please bear
with me. I need some help converting..

In my asp project I have some styles in my head tag that change
according to a parameter passed in in the query string - fontfamily
is the variable that I store the value of the parameter in within my
asp code, and then I place that into the styles see below..

<style type="text/css">
a:link,a:visite d,a:hover,a:act ive{font...
..ebartext{font-family:<%=fontf amily%>;...
..price{font-family:<%=fontf amily%>;fon...
..textfont{font-family:<%=fontf amily%>;...
..{font-family:arial,sa ns-serif;font-si...
table{backgroun d-color:transpare nt;}
..ebaylogo{posi tion:absolute;z-index:40...
..ebarlogo{posi tion:absolute;z-index:40...
..ebarlogotext{ font-family:arial,sa ns-s...
..ebarcontainer {position:absol ute;left:...
..clipdiv{posit ion:absolute;le ft:0px;to...
</style>

I am not sure how to change my stylesheet from within c# and replace
it with a value passed in as a parameter.

I have gotten the value into the string variable fontfamily, but not
sure how to place that within the style??

//in my c# code default.aspx.cs I get the parameter passed in fine..
string fontfamily = "" + Request.QuerySt ring["fontfamily "];

Can anyone help?
Oct 17 '08 #1
1 2226
In ASP.NET you will need to do this from within one of the Page events, such
as Load. Here is a class I wrote (with some help from the internet and these
newsgroups):

public class CustomStyle : System.Web.UI.W ebControls.Styl e
{
private System.Web.UI.C ssStyleCollecti on currstyles;

public CustomStyle(Sys tem.Web.UI.CssS tyleCollection custom) {
this.currstyles = custom; }
public CustomStyle(str ing cssvalue)
{
System.Web.UI.C ssStyleCollecti on tempstyle = new
System.Web.UI.W ebControls.WebC ontrol(System.W eb.UI.HtmlTextW riterTag.Unknow n).Style;
tempstyle.Clear ();
tempstyle.Value = cssvalue;
this.currstyles = tempstyle;
}

protected override void
FillStyleAttrib utes(System.Web .UI.CssStyleCol lection
attributes,Syst em.Web.UI.IUrlR esolutionServic e urlResolver)
{
base.FillStyleA ttributes(attri butes, urlResolver);
foreach (string currkey in this.currstyles .Keys) { attributes[currkey] =
this.currstyles[currkey]; }
}
}

In your Page's Load event use a statement similar to the following:

this.Header.Sty leSheet.CreateS tyleRule(new CustomStyle("fo nt-size:12px;"),
null, ".style1");

You will notice that this statement includes two key parts, the
CreateStyleRule method, which you can see details about at:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20 .en/cpref13/html/M_System_Web_UI _IStyleSheet_Cr eateStyleRule_3 _9de1b1b6.htm
For the CreateStyleRule method you will be supplying three parameters, the
Style object returned by a new CustomStyle, null, and a String specifying
the CSS selector.

And the CustomStyle constructor. Although the CustomStyle class has two
constructors, the only one I ever use is the second one, which simply takes
a String of CSS declarations, just as you would enter them in a *.css file,
<styletags, or HTML style attribute.

It took me a while and a lot of help to figure all this out (I actually got
the original CustomStyle class online, but I had to modify it to include the
second constructor), and I have been doing ASP.NET for a couple years now,
so don't feel bad about not knowing what to do. Hopefully everything I have
supplied will be enough to fix your problem. Good Luck!
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Michelle Sollicito eBarster" <mi************ ****@gmail.comw rote in
message
news:a5******** *************** ***********@v56 g2000hsf.google groups.com...
Ok I know a lot of asp but not a lot of asp.net and C# so please bear
with me. I need some help converting..

In my asp project I have some styles in my head tag that change
according to a parameter passed in in the query string - fontfamily
is the variable that I store the value of the parameter in within my
asp code, and then I place that into the styles see below..

<style type="text/css">
a:link,a:visite d,a:hover,a:act ive{font...
.ebartext{font-family:<%=fontf amily%>;...
.price{font-family:<%=fontf amily%>;fon...
.textfont{font-family:<%=fontf amily%>;...
.{font-family:arial,sa ns-serif;font-si...
table{backgroun d-color:transpare nt;}
.ebaylogo{posit ion:absolute;z-index:40...
.ebarlogo{posit ion:absolute;z-index:40...
.ebarlogotext{f ont-family:arial,sa ns-s...
.ebarcontainer{ position:absolu te;left:...
.clipdiv{positi on:absolute;lef t:0px;to...
</style>

I am not sure how to change my stylesheet from within c# and replace
it with a value passed in as a parameter.

I have gotten the value into the string variable fontfamily, but not
sure how to place that within the style??

//in my c# code default.aspx.cs I get the parameter passed in fine..
string fontfamily = "" + Request.QuerySt ring["fontfamily "];

Can anyone help?

Oct 18 '08 #2

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

Similar topics

4
2470
by: mustafa | last post by:
Dear sir , I have built my application in visual basic 6.0 and crystal Report8.5 , Now i migrated my application to VB.net using the upgrade wizard.My visual basic form is upgraded to vb.net but my .dsr file that i created using crystalReport is not migrated , when i try to convert it into .rpt file using add new item in Vb.net Envs it...
29
3872
by: Armand Karlsen | last post by:
I have a website ( http://www.zen62775.zen.co.uk ) that I made HTML 4.01 Transitional and CSS compliant, and I'm thinking of converting it into XHTML to learn a little about it. Which XHTML variant would you recommend? The w3c HTML validator mentions XHTML 1.0 Transitional, Basic, Strict, and XHTML 1.1. Would I be able to make my existing CSS...
8
5725
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple output html files. The problem is while reading through the worddoc paragraph,the special characters are not identified. So in the xml file,it's...
5
2507
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant applications. I am testing an upgrade of all of the sites and have converted the main root site...although not necessarily fixed any issues. I move on...
3
2408
by: Mary | last post by:
Hi, Does anyone know of any software out there that would convert an application written in VBScript to either VB.NET or C#/C++ quite quickly for me, or will I have to re-write the application myself. Any help much appreciated.
2
6167
by: Map Reader | last post by:
Greetings, I am converting an old VB6 application to use .NET. One of the old controls loads icons from the disk and displays them. However, the transparent color turns to blue somewhere in the process. I narrowed it down to the conversion to IPictureDisp by first loading and saving the icon as a bitmap with no problems; and then repeating...
12
3140
by: Frederik Vanderhaeghe | last post by:
Hi, I have a problem converting text to a double. Why doesn't the code work: If Not (txtdocbedrag.Text = "") Then Select Case ddlBedrag.SelectedIndex Case 0 Case 1
7
2687
by: Tor Aadnevik | last post by:
Hi, I have a problem converting values from Single to double. eg. When the Single value 12.19 is converted to double, the result is 12.1899995803833. Anyone know how to avoid this? Regards Totto
4
3178
by: gg9h0st | last post by:
i'm a newbie studying php. i was into array part on tutorial and it says i'll get an array having keys that from member variable's name by converting an object to array. i guessed "i can get public members but not protected, private, static members"
2
5852
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 ...... Deadlocked Statement: Type : Dynamic Operation: Execute
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6286
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.