faqts : Computers : Programming : Languages : C#

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

11 of 39 people (28%) answered Yes
Recently 3 of 10 people (30%) answered Yes


What is C# equivalnet of Java script 'Eval' function?

Jul 6th, 2006 03:57
Deepak Sharma, Rajesh Parab,

Set a compiler reference (using the browse feature, off Add Reference in
the Solution Explorer) to the Microsoft.VisualBasic dll, which lives in
C:\WINNT\Microsoft.NET\Framework\v1.0.3705\Microsoft.VisualBasic.dll. This
will give you access to the eminently useful CallByName function.
* Add the hyperlinks as public members of the "code behind" page - by
default the VS editor makes them protected, so they need to be changed if
you use the editor to add them from the toolbox.
You can then do the following:
//Create a hyperlink object
HyperLink h;
//Call the public interface of the current class - i.e. the web page - to
//a reference to the HyperLink1 object
h = (HyperLink)Interaction.CallByName(this, "HyperLink1",CallType.Get);
//Set a property
h.Height = 200;
Full code:
public class WebForm2 : System.Web.UI.Page
public System.Web.UI.WebControls.HyperLink HyperLink1;
public System.Web.UI.WebControls.HyperLink HyperLink2;
private void Page_Load(object sender, System.EventArgs e)
// Put user code to initialize the page here
HyperLink h;
h = (HyperLink)Interaction.CallByName(this, "HyperLink1",CallType.Get);
h.Height = 200;
Hope this is useful