Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / August 2006

Tip: Looking for answers? Try searching our database.

How do I add server -side code at runtime?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bestwerx@gmail.com - 22 Aug 2006 12:49 GMT
I am building an application that is totally data driven. The pages are
built from scratch at runtime.I have everything working fine. Now all I
need to do is to have the ability to add code both server-side and
client-sie at runtime. I think I have pretttty much figured out the
client side part. My problem is the servre-side code. How do i inject
and/or run server-side code (frfom the database) at runtime?
Gaurav Vaish (www.EduJini.IN) - 22 Aug 2006 17:43 GMT
Are you generating C#/VB.Net code on the fly?
Yikes! Well... you would be needing
System.CodeDom.Compiler.CSharpCodeProvider or
System.CodeDom.Compiler.VBCodeProvider

for the code to be compiled on the fly.

But I am damn sure... there are better things around. May be you can share
some more information about your website / application!

Signature

Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.org
http://www.edujini.in | http://webservices.edujini.in
-------------------

>I am building an application that is totally data driven. The pages are
> built from scratch at runtime.I have everything working fine. Now all I
> need to do is to have the ability to add code both server-side and
> client-sie at runtime. I think I have pretttty much figured out the
> client side part. My problem is the servre-side code. How do i inject
> and/or run server-side code (frfom the database) at runtime?
Scott - 22 Aug 2006 20:36 GMT
Thx
I will try this
And yes, I am generating code on the fly
sw

> Are you generating C#/VB.Net code on the fly?
> Yikes! Well... you would be needing
[quoted text clipped - 18 lines]
> > client side part. My problem is the servre-side code. How do i inject
> > and/or run server-side code (frfom the database) at runtime?
dave.dolan - 23 Aug 2006 18:24 GMT
Don't forget about DynamicMethod.  You can create a delegate to an arbitrary
method, constructor, or property accessor anywhere... and it works lots
faster than the Invoke on MethodInfo via reflection.  (You can cache
delegates in a dictionary, for example, and have the ability to access
properties or methods by a string name)

There is an introduction to this type of thing on a CodeProject article:
http://www.codeproject.com/csharp/DynamicMethodDelegates.asp?print=true

There's also something on MSDN about it, but it's not very helpful.

If you want to get really fancy and use generics that determine their type
parameters at runtime, then you'll have to do something like this :
http://musingmarc.blogspot.com/2006/08/how-to-do-late-dynamic-method-creation.html (Marc is one of my newfound hero's)

> Thx
> I will try this
[quoted text clipped - 23 lines]
> > > client side part. My problem is the servre-side code. How do i inject
> > > and/or run server-side code (frfom the database) at runtime?
MRe - 24 Aug 2006 14:33 GMT
I found http://www.west-wind.com/presentations/dynamicCode/DynamicCode.htm 
to be a pretty good reference on doing this.. put me right off the idea :)
You could also use the Script control (though you'll have to use vbscript or
javascript) - Add a reference to the COM \ Microsoft Script Control 1.0 and
do like..

 <snip>
 ScriptControl script = new ScriptControl();
 script.Language = "vbscript";
 script.AddObject("joe", new ken(), true);
 Response.Write(script.Eval("(1 + 3) * joe.bob"));
 </snip>

 [ComVisible(true)]
 public partial class ken
 {
   public int bob = 3;
 }

..too easy!

Regards,
Eliott

| Thx
| I will try this
[quoted text clipped - 23 lines]
| > > client side part. My problem is the servre-side code. How do i inject
| > > and/or run server-side code (frfom the database) at runtime?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.