List Info

Thread: C-Sharp (C#) Group: C# TextBox value sent to Javascript




C-Sharp (C#) Group: C# TextBox value sent to Javascript
user name
2006-01-23 17:29:04
I have written an application in C#.Net. I am creating a pop
up window
using Javascript. This program is run locally so the pop up
will not be
a problem. I am trying to pass a varaible from C# into the
javascript.
I have entered the code below. Any help would be
appreciated.

string sResponse;
string sRedirect = "http:/
/localhost/LeaseTest/Navistar.aspx?name=' +
Form1.txtDriver.Value + '"; // + '&effdate=' +
this.txteffDate.Text +
'&tractor=' +
this.ddltracNum.SelectedValue.ToString()";

sResponse = "<script
language=JavaScript>window.open('" + sRedirect +
"', 'Agreement',
'width=600,height=600,top=200,lleft=200,toolbars=Yes,scrollb
ars=yes,status=yes,resizable=yes');</script>";
Response.Write(sResponse);

C-Sharp (C#) Group: Re: C# TextBox value sent to Javascript
user name
2006-01-27 12:41:25
Hi,
   You are trying to pass the value of a control to
javascript.

Do you mean the value entered by the user or a value that u
got from
database.

If it is database, the way you have written will be ok.

But if you want to pass the value which is entered by user ,
you have
to go for the option

RegisterScriptBlock("itemname","javascript&qu
ot;)

I dont suggest you going for Response.Write, (ofcourse this
also work,
but it shows blank screen for a while right ?)

Instead go for "Registerstartupscript". You may
find some help in MSDN
regarding this.

Happy programming!

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )