views:

73

answers:

1

I have a JavaScript that generates HTML on my web page (AJAX control). Now I need to create a ASP.NET Control that is visible at design time. It should look exactly like the original AJAX control. Any ideas about how to execute JavaScript at design time? Unfortunately I cannot create all the required HTML in .Net as it is too large and complex.

Here is the possible solution:

  1. Create an invisible WebBrowser control provided with Windows Forms.
  2. Load and execute JavaScript inside WebBrowser control.
  3. Extract generated HTML.
  4. Render extracted HTML on web page.

Are there any better approach?

A: 

Why do you need an ASP.NET control at design time? ASP.NET controls can only be run within the context of a web server. If you are trying to get some design time functionality, you'll need to create a plug in for visual studio.

Running javascript in Visual Studio isn't possible. You'll have to use a browser for client-side javascript or the command line to run server-side javascript.

I'd say 3 or 4 is your best bet.

You are better off using the existing technologies and making them work than trying to hack together a solution (running javascript at design time).

Extract the html/javascript into a plain html page and use something like firebug to see it in action.

Update

Where are the settings stored? Are they local? In a database. You can call a web page from within Visual Studio. The Start-up tab makes a call to MSDN to get it's content. You could probably do something similar.

Chuck Conway