Sending parameters to a JavaScript function from C#

see07

Regular
Joined
Apr 16, 2004
Messages
78
Location
Mexico City
Hello:
I need to send some parameters from C# to a JavaScript function, but when I run my project is generating an error “xxxxxxx” is not defined. Where “xxxxxxxx” is first parameter’s value.
My script in C# is:
string pru = "<script language = javascript> MakePage(" + Nombre + "," + Ciudad + "," + Compa + "," + Edad + ");</script>";
if(!this.IsStartupScriptRegistered("Pb"))
{
Page.RegisterStartupScript("Pb", pru);
}
My JavaScript function is:
function MakePage(name,town,roonmate,age)
{
-------
-----
-----
}
What is wrong with my code?
I’ll appreciate your help.
A.L.
 
Be sure that Nombre, Ciudad, Compa and Edad are all number. Else... if they are string... take care to put some ' to make sure that they are all defined as a string.
 
Back
Top