eddyperu
asked on
How can I make variables from SWFObject dynamic?
hi:
I am using SWFObject and I need for all of the embedSWF values being pass from codebehind ( C# )
In this line:
swfobject.embedSWF("Value1 ", "myContent", "value2", "Value3");
[swfUrl ], [DIV-ID] , [Width] , [Height]
I need to pass these values ( Value1, Value 2 and Value3 ) using codebehind.
Thanks for all your help
I am using SWFObject and I need for all of the embedSWF values being pass from codebehind ( C# )
In this line:
swfobject.embedSWF("Value1
[swfUrl ], [DIV-ID] , [Width] , [Height]
I need to pass these values ( Value1, Value 2 and Value3 ) using codebehind.
Thanks for all your help
** correction of point 2
In the code behind, you have to register the java script using registerclientscriptblock
In the code behind, you have to register the java script using registerclientscriptblock
ASKER
may be asking this question can be a little silly but I a new in coding... Would you mind to explain me the term "the client script is already register"? register in what?
what happens if the javascript if not registered? How do I register?
THank you again for all your help!
what happens if the javascript if not registered? How do I register?
THank you again for all your help!
Register the java script block with the page. html\javascript is in the aspx (html portion of asp.net web page) and code behind (cs\vb.net) code is in the aspx.cs (code behind portion of the asp.net web page)
registering the client script means that it is being registered with the page. An equivalent java script snippet is emitted at runtime.
Read this for better understanding
http://msdn.microsoft.com/en-us/library/0skaxdwf.aspx
IsClientScriptBlockRegiste red method is used to check if its already registered
RegisterClientScriptBlock method is used to register the script block
You cannot register more than one script block with the same key. you can think of Key\Value pairs where keys are unique.
Hope u understand
registering the client script means that it is being registered with the page. An equivalent java script snippet is emitted at runtime.
Read this for better understanding
http://msdn.microsoft.com/en-us/library/0skaxdwf.aspx
IsClientScriptBlockRegiste
RegisterClientScriptBlock method is used to register the script block
You cannot register more than one script block with the same key. you can think of Key\Value pairs where keys are unique.
Hope u understand
ASKER
Hi,
May be I am doing something wrong here, Would you mind to check my code?
There is an error saying that the Element "script" is missing the its closing tab.
I am guessing somewher ein the AppendForm I forgot to close the script.
Thanks
May be I am doing something wrong here, Would you mind to check my code?
There is an error saying that the Element "script" is missing the its closing tab.
I am guessing somewher ein the AppendForm I forgot to close the script.
Thanks
protected void Page_Load(object sender, EventArgs e)
{
// Define the name and type of the client scripts on the page.
String csname = "swfObjectScript";
Type cstype = this.GetType();
string value1 = "SWFDocuments/SCICalculatorUK.swf";
string value2 = "myContent";
string value3 = "600";
string value4 = "680";
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
// Check to see if the client script is already registered.
if (!cs.IsClientScriptBlockRegistered(cstype, csname))
{
System.Text.StringBuilder cstext = new System.Text.StringBuilder();
//StringBuilder cstext = new StringBuilder();
cstext.Append("<script type=\"text/javascript\">");
cstext.AppendFormat("swfobject.embedSWF(\"{0}\",\"{1}\",\"{2}\",\"{3}\");", value1, value2, value3, value4);
cstext.Append("</script>");
cs.RegisterClientScriptBlock(cstype, csname, cstext.ToString(), false);
}
}
ASKER
I check and I figured out the problem but still I don't see the Swf in the page.
What I am doing wrong??
What I am doing wrong??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
check here for more information on ClientScriptManager
http://msdn.microsoft.com/en-us/library/0skaxdwf.aspx
http://msdn.microsoft.com/en-us/library/0skaxdwf.aspx
ASKER
Thanks
<script type="text/javascript" src="swfobject.js"></scrip
2. In the code behind, You will have call
// Define the name and type of the client scripts on the page.
String csname = "swfObjectScript";
Type cstype = this.GetType();
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
// Check to see if the client script is already registered.
if (!cs.IsClientScriptBlockRe
{
StringBuilder cstext = new StringBuilder();
cstext.Append("<script type=\"text/javascript\">"
cstext.AppendFormat("swfob
cstext.Append("</script>")
cs.RegisterClientScriptBlo
}