Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Microsoft.JScript vs Microsoft.VisualBasic

Status
Not open for further replies.

Kavius

Programmer
Apr 11, 2002
322
CA
I am converting an ASP application to an ASP.Net application. In order to serve up data easier, I wrote a class that renders a paged datagrid based on a sql statement and a couple of column definitions.

In order to bind the data to the column I specify the html formatting, and in some cases, code which may change the display based on the data values for that row.

I was hoping to use the JScript eval function to replace the VBScript eval function, but found that I can't. Based on the ability to reference things like vbNewline or Split from VB, I was expecting to be able to reference the eval function from JS but I would apparently have to rewrite the whole thing in JScript to do that.

Does anyone have any suggestions on the databinding/eval problem?

But more importantly (because I don't understand and I hate not understanding)...
[tt]
I can do this (from C#):
result = Microsoft.VisualBasic.Conversion.Fix(12.5)

I was expecting to be able to do this (or something like it):
result = Microsoft.JScript.IDontKnow.eval(exp)
[/tt]
Why is it that I can reference the VB functions, but not the JScript functions?

 
Not sure. Maybe JScript DLL is not registered as a global dll (gac) like vb and c sharp are. JScript is not instrinsic like the others are.
I tested it and this does work:
Right click on references and add the jsharp dll. It is the only jsharp in the list on the .Net tab.
You can also navigate straight to in a folder like:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322
 
Alright, finally figured this out. I don't know if anyone cares but this is the answer. If this doesn't make sense... well ask and I can give the (said in a great booming voice), "Huge Indepth Answer of Answers!!!"

1. eval not available if not in JScript:

"eval" is available in JScript, the problem is that it is not designed for use outside of JScript. It requires a compiler pointer. This is the environment being used to process the commands and needs to be the one being used process the rest of the instructions (so that other variables are available).

I would say it is possible for a person to find access to this pointer and therefore be able to use this function, but currently this is beyond me.

2. How do I work around this problem?

I ended up rewriting the my ASP Datarepeater to take a function pointer. In ASP, after the data was placed in the string, the datarepeater would look for inserted code and run it with eval; now, in ASP.NET, it looks for inserted code and places the name of the function, and all of the parameters, into a class and calls the function specified by the parent class.

The parent class can then do any special processing on the data that is required for that particular instance and returns the string which replaces the inserted code.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top