Eval function in C#?

Hi Everybody,

     Is there any Eval function(javascript) in C#? Waht I would like to do is if certain condition is met, I would like to execute another .aspx web page that will create a .jpeg image so taht the calling web page can use it from the saved location.

    Is there any functions that I can use to get the above functionality?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I posted a similar question.  Here was the result:

Can't you do something like this:

if(someCondition == true) {
    myImage.ImageUrl="/myScriptThatDisplaysAnImage.aspx?imageID=" + someID;

<asp:Image id="myImage" runat="server" />
payal1711Author Commented:

  I dont think myImage.ImageUrl will do what I want. I want the script in the .aspx web page to be executed that creates the image on the fly based upon the argument passed to it.

  so for example,

   so makeimage.aspx page will execute a script that will create a jpeg image  with "Monkey" written on it.

   .imageUrl just specifies the path to the image. it will not execute the .aspx file

   Let me go through the link you have provided and see if something is helpful there..

You could also use following solution (at least we did):

In your calling aspx (or html) page you set the url for your image as


This new aspx-Page is nearly empty, it just contains the line:

<%@ Page language="c#" Codebehind="ImageCreator.aspx.cs" AutoEventWireup="false" Inherits="NyNamespace.ImageCreator" %>

The Codebehind-Class then does the magic. You can write whatever you want to your image (gr.DrawString).

namespace MyNamespace
      /// <summary>
      /// Zusammenfassung für Umsatzverlauf.
      /// </summary>
      public class ImageCreator: System.Web.UI.Page

            private void Page_Load(object sender, System.EventArgs e)

            private void zeichneGrafik()
                  GraphicObject go = (GraphicObject)Session[BRConstants.GRAPHIC_OBJECT];

                        // Anlegen der Bitmap      
                        Bitmap bm = new Bitmap(go.Breite,go.Hoehe);             
                        Graphics gr = Graphics.FromImage(bm);
                        gr.SmoothingMode = SmoothingMode.AntiAlias;  // Geradenstücke werden glatter


                        bm.Save(Response.OutputStream ,ImageFormat.Jpeg);
                        return (0);
                  catch(Exception ex)
                        Response.Write( "Fehler: " + ex.Message + "<br>");



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Addition: We passed the parameters of the image by an special object in the session because a lot of data was needed.
payal1711Author Commented:
Thanks a lot Timo,

     Your solution is perfect, but I changed the design of my code and did a workaround and I dont want to change is again now...

 but anyways thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.