• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1085
  • Last Modified:

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
0
payal1711
Asked:
payal1711
  • 2
  • 2
1 Solution
 
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
 
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now