Link to home
Start Free TrialLog in
Avatar of jksugu
jksugu

asked on

Creating Dynamic HTML File - using windows C# application.

Hi,

I need to create and save set of dynamic html page using windows c# application.
eg: If user clicks on preview   button i hv to create a html file (dynamically based on the data avilable on DB) and save it in a temp location and that should be open it automatically(it should be done automatically without knowing the use).

Can anyone help me out in this regard.
Avatar of purpleblob
purpleblob

Can you supply some further information - is this button in a WebForm (i.e. HTML or ASP.NET or similar) or is this a Windows form ?

Creating a file from C# is pretty simple and outputting HTML is pretty simple also so can you ellaborate on precisely what problems/issues you have with coding this ?
ASKER CERTIFIED SOLUTION
Avatar of TransBind
TransBind

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
strmEditWrite.Write()  accepts a context for your html you could define a (String htmlVar) and pass to it

String htmlVar = "<html><head></head><body><b>this is bold</b></body></html>";
In case you are wondering how to open a new windown when a user clicks on a button which is a server control button you can do it in two ways in the click event of the Button Webcontrol register a script code block or add an attribute to your button webcontrol.

Example for you, this shows how you can add client side javascript to your server control button using first method:

private void Page_Load(object sender, System.EventArgs e)
{
     //Button1 is a button id name
      Button1.Attributes["onclick"]="javascript:alert('Hello! Focus lost from text box!!');";
}


From a windows platform (not asp)


using system.Diagnostics


                  ProcessStartInfo qOptions = new ProcessStartInfo(@"C:\Program Files\Internet Explorer\iexplore", @"C:\temp\test.html");

                  qOptions.UseShellExecute = false;  // set to true to make silent/background
                  Process myCmd = Process.Start(qOptions);
You said "windows c# application", so I'll assume you don't want an ASP.NET solution.
_TAD_'s solution is a good one, however if you don't want to launch an IE instance in a seperate process, you can embed a MSHTML object inside the application as a control for previewing your generated page.

If this sounds like what you want, I'll provide more information for you.


There are ways to open default browser instead of forcing Internet Explorer, however I find seeFlat's proposal very interesting, and from a programming architech point of view using seeFlat's proposal would be much more sound (provided that there isn't a ton of overhead).


seeFlat>  If you have some code or web pages handy I'd like to take a peek at them.  Currently a lot of things I do tend to use ProcessStartInfo and Process Classes.  But if I can reign in some of those 3rd party tasks and pull them into the umbrella of .Net I think I'd be better off.  
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial