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?

    Thanks,
    Payal
LVL 1
payal1711Asked:
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.

hendridmCommented:
I posted a similar question.  Here was the result:
http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21090117.html

Can't you do something like this:

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

<asp:Image id="myImage" runat="server" />
0
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,
 
       makeimage.aspx?imageid=Monkey

   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..

 Thanks,
 Payal
0
tstoeckigtCommented:
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

ImgUmsatz.ImageUrl="ImageCreator.aspx";

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)
            {
                  zeichneGrafik();
            }


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

                  try
                  {
                        // 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);
                        bm.Dispose();
                        return (0);
                  }
                  catch(Exception ex)
                  {
                        Response.Write( "Fehler: " + ex.Message + "<br>");
                  }
            }
      }
}

Ciao
Timo

0

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
tstoeckigtCommented:
Addition: We passed the parameters of the image by an special object in the session because a lot of data was needed.
0
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.
 -Payal
0
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
C#

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.