| | |
transfer data from an asp .net page into a javasscript script
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
ASP.NET Syntax (Toggle Plain Text)
string script = "<script type=\"text\\javascript\">function(){alert('some data');};</script>"; Page.RegisterClientScriptBlock("myscript", script);
That's an easy way. There are many others like AJAX google for that.
Last edited by hollystyles; Jul 28th, 2006 at 1:15 pm.
There is more than one way to register the script. Maybe RegisterStartupScript may work better as it waits till the page is fully loaded in the browser before firing. Also I had my slash the wrong way around in the "text/javascript" attribute of the script tags.
HTML Page:
[HTML]<html>
<head>
<script type="text/javascript">
function myFunction(data)
{
alert(data);
}
</script>
</head>
<body>
</body>
</html>[/HTML]
ASP.NET page
HTML Page:
[HTML]<html>
<head>
<script type="text/javascript">
function myFunction(data)
{
alert(data);
}
</script>
</head>
<body>
</body>
</html>[/HTML]
ASP.NET page
ASP.NET Syntax (Toggle Plain Text)
string data = "Hello!"; string script = "<script type=\"text/javascript\">"; script += "myFunction('" + data + "');</script>"; Page.RegisterStartupScript("myscript", script);
Last edited by hollystyles; Aug 2nd, 2006 at 10:17 am.
![]() |
Similar Threads
- Linking to asp.net page from html page (ASP.NET)
- How To Hyperlink Normal HTML page with ASP.NET Page? (ASP.NET)
- This ASP.NET page is not working...!!! SOS (ASP.NET)
- ASP.NET Page Life Cycle (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: Less than a beginner!
- Next Thread: Dynamically Adding Fields to a DetailsView
| Thread Tools | Search this Thread |
.net activexcontrol advice ajax alltypeofvideos appliances asp asp.net bc30451 beginner bottomasp.net browser button c# cac checkbox class commonfunctions confirmationcodegeneration countryselector css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock deployment development dgv dropdownlist dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash formatdecimal forms formview gridview gudi iframe iis javascript listbox microsoft mono mouse mssql multistepregistration news novell numerical objects opera panelmasterpagebuttoncontrols problem radio redirect registration relationaldatabases reportemail rotatepage schoolproject search security sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visualstudio vs2008 web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers






