Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Below code is my aspx page...from aspx.cs page i have to change value of roomid using label or text.

JavaScript
<script type="text/javascript">
var targetID = "scribblar";
var flashvars = {};
/* pass necessary variables to the SWF */
flashvars.userid="0"; 							 flashvars.roomid = "uh2b9pm";
flashvars.username = "saju25";


This is the aspx code

C#
flashvars.roomid ="uh2b9pm"


i have to change roomid="some other value" from aspx.cs page using textbox...


Please tell me how to solve.......
Posted
Updated 13-Jul-12 0:52am
v2

1 solution

Well there is one shortcut we used to use during the ASP days, this still works in ASP.NET
In the page codebehind declare a public property say public int MyInteger
In the aspx put this

XML
<script>
    function GetMyValue()
    {
     var someVar = <%=this.MyInteger%>;
     //Do something
    }
</script>



To do it nicely, you can use RegisterClientScriptBlock[^]

C#
string script = string.Format("var myVariable = '{0}';", vaiable.ToString());
if (!ClientScript.IsClientScriptBlockRegistered("myScript"))
{
    ClientScript.RegisterClientScriptBlock(typeof(_Default), "myScript", script, true);
}
 
Share this answer
 
v2
Comments
Prasad_Kulkarni 13-Jul-12 7:06am    
+5!
ANOOP CL NAIR 13-Jul-12 7:10am    
Can u please explain it...

flashvars.roomid ="uh2b9pm"

For example if i change textbox = 1 then it will change the value of flashvars roomid="1"


i tried like this flashvars roomid="textbox1.text", but its showing error...please tell me easy method to solve this

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900