The ASP.NET runtime can (also) be hosted from a desktop-application (that's one of the links provided), and probably much the same way in a Windows Service.
It might be a bit overkill, so be sure to check out whether it's worth the investment in time
If your page conforms to a fairly well defined specification, you might want to consider using XML and XSLT to output your HTML page. Here's[^] more information.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
I'm probably overthinking this as usual, but for a service, what about a HTML generator class? It could have a list of HTMLTags, and each HTMLTag would have another list of HTMLTags for nested tags, an InnerText property and a Dictionary<string, string> for the attributes. Then when you wanted to generate the HTML, you would iterate through each HTMLTag and recursively write the string approximation of each HTMLTag. If you wanted to be really nifty, you could override the ToString function to make this easier
I'm feeling rather generous today, so I'll even give you "teh codz" for once. Something like this:
publicclass HTMLGenerator
{
public List<HTMLTag> Tags { get; privateset; }
public HTMLGenerator(params HTMLTag[] tags)
{
this.Tags = new List<HTMLTag>(tags);
}
publicstring GetHTML()
{
StringBuilder sb = new StringBuilder();
foreach(HTMLTag tag inthis.Tags)
sb.Append(tag.ToString());
return sb.ToString();
}
}
publicclass HTMLTag
{
public List<HTMLTag> Subtags { get; privateset; }
publicstring InnerText { get; set; }
publicstring Name { get; set; }
public Dictionary<string, string> Attributes { get; privateset; }
public HTMLTag(string name, string innerText)
{
this.Name = name;
this.InnerText = innertext;
this.Subtags = new List<HTMLTag>();
this.Attributes = new Dictionary<string, string>()
}
publicoverridestring ToString()
{
//The main meat of the code goes here
StringBuilder sb = new StringBuilder();
//Append the start and the name of the HTML tag
sb.AppendFormat("<{0} ", this.Name);
/* Then, iterate through each attribute in the Dictionary, appending it in string
* form. Note: you have to handle any special character encoding yourself */foreach(string attribute inthis.Attributes)
sb.AppendFormat("{0}=\"{1}\" ", attribute, this.Attributes[attribute]);
if(this.Subtags.Count > 0)
{
//Close the tag and recurse for every child tag
sb.AppendLine(">");
foreach(HTMLTag tag inthis.Subtags)
sb.AppendLine(tag.ToString());
sb.AppendFormat(">/{0}<", this.Name);
}
else/* If there aren't any subtags, we can just close it like this, without
* writing an ending tag */
sb.AppendLine(" />");
return sb.ToString();
}
}
[edit] Stretched the screen; fixed
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
I want to load a button in taskbar,
Such that I can give some options to user for selecting.
For example, if there is the button of open office 2.1 Quickstarter, and if I rightclick it, there comes some options like Text Document, spreadsheet, Presentation, Drawing, database etc.,
In the same way, If I right click the button which is loaded through my program, therre should come some options for user to select.
How to do these in c#?
A callback was made on a garbage collec delegate of type 'CrystalDecisions.ReportAppServer.DataSetConversion!CrystalDecisions.ReportAppServer.DataSetConversion.DataSetConverter+CrdbAdoPlusDelegate::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called.
Hi, I'm ceating a Setup and deployment project using C# in which i've to collect user id and password. for this I'm Texboxes dialog. now i want to apply validation on Texboxes dialog so that user can not move further without providing user id and password. can one help me?
// Now recurse down the directories
DirectoryInfo[] dirs = dirInfo.GetDirectories();
foreach (DirectoryInfo dir in dirs)
{
deleteOldFiles(dir.FullName, olderThanDate);
}
}
So, what's your question? If you want to change your program so that it deletes folders which are n hours old, instead of n days old, then you change deleteOldFiles(path, DateTime.Now.AddDays(-DaysOld)); to deleteOldFiles(path, DateTime.Now.AddHours(-DaysOld));
And please, put your code in <pre> tags. It makes it much easier to read
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
I need help from u all. I'm using combobox control in my program. My problem is if i select the items more than once from combobox it should display an error message.
Hi All,
I have Class library with name and namespace Dipak.DataAccess and within this name space there is class called DataAccess.
I have another class library with name and namespace Dipak.ESchool.Data and within this namespace there is class called StudentData. Now i have added reference of Dipak.DataAccess in Dipak.ESchool.Data and i have added using Dipak.DataAccess statement in StudentData class .
While calling method of Dipak.DataAccess i have to use full name like DataAccess.DataAccess.GetDataSet(),after adding using Dipak.DataAccess statement.
And when i changes namespace from Dipak.ESchool.Data to ESchool.Data i need not to give full name for method call i am able call with classname.methodname, no need to add namespace name.
Can any one explain me why it is so?
And what i need to do for correcting above problem.
<br />
namespace Dipak.DataAccess<br />
{<br />
publicclass DataAccess;<br />
{<br />
}<br />
//-------------------------------------------------<br />using Dipak.DataAccess<br />
using Dipak.ESchool.Common;<br />
<br />
namespace Dipak.ESchool.Data<br />
{<br />
publicclass StudentData<<br />
{<br />
DataAccess.DataAccess.GetDataSet()<br />
//i want this call to be like DataAccess.GetDataSet()<br />
}<br />
}<br />
you have to use the fullname DataAccess.DataAccess.GetDataSet because the compiler doesn't know if you write only one DataAcces what you mean: namespace or class.
I suggest not to use the same name for a class and a namespace. That can cause too much trouble as you see.
Regards
Sebastian
P.S.: What about naming the DataAccess-namespace "DataAccessLayer"?
Thanks for your reply...
I tried using ur solution...it works...
But as far as concept is concerned ....i have included using statement as using Dipak.DataAccess....so at this point compiler will be knowing the clearly that this name space is referenced...what matters if same class name is there in namespace...
what matters if same class name is there in namespace...
What matters is that the M$ coders didn't provide for this scenario. FWIW I agree with you, but the fact remains that we have to work with the tools we have.
If this is the first of VSs little annoyances that you have encountered, then you are a lucky, lucky chap.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
thanks buddy..
but as i have mentioned in my problem description that if i changes my namesapce from Dipak.ESchool.Data to only ESchool.Data it works fine.
But with Dipak.ESchool.Data i have to make call like DataAccess.DataAccess.GetDataSet().
As per naming standerds for namespace we follows Compnyname.projectname.namespacename and thats what i have done...
Dipak my compny name....DataAccess and ESchool my Project name ....
Dear Developers,
I am user level settings...
How To change the path of "user.config"
I want to create it in my Project Output directory or target directory On Deployment.Generally its been created in local settings..
Thanking you
I am creating setup project fro my .Net 2.0 application, how can I add .Net 2.0 framework along with the setup project so that I can Install the application in a machine even though there is no .Net framework installed
Last Visit: 31-Dec-99 18:00 Last Update: 22-Sep-24 15:34