| | |
transfer data from an asp .net page into a javasscript script
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
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 2.0 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer c# cac checkbox class commonfunctions compatible content contenttype countryselector courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv formatdecimal formview gridview gudi iframe iis javascript listbox menu microsoft mouse mssql multistepregistration nameisnotdeclared news opera panelmasterpagebuttoncontrols problem redirect registration relationaldatabases reportemail schoolproject security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webdevelopment webprogramming webservice youareanotmemberofthedebuggerusers






