|
|
Rank: Newbie Groups: Member
Joined: 5/14/2010 Posts: 9 Points: 27 Location: USA
|
I am having trouble accessing the GetPosition() from the server side.
If I display it in a messagebox, it works, but I can't doesn't set my hidden field properly.
This is the example that works: Javascript Code: function GetPositionLeft() { var pos; pos=ASPNetMedia.FlashVideo("FlashVideoLeft").GetPosition(); alert(pos); }
This is the example that does not work: On ASP.NET User Control (ascx file): <asp:HiddenField ID="hiddenfield" runat="server" />
Javascript Code: function GetPositionLeft() { var pos; var hidden = document.getElementById('hiddenfield'); pos=ASPNetMedia.FlashVideo("FlashVideoLeft").GetPosition(); alert(hidden.value); }
Please help. I have tried several different ways and can't seem to find a way to access any ASP.NET controls from javascript or access any Javascript variables from the server side. I need to be able to access the position and set the position initiated from a C# procedure.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 7/26/2007 Posts: 676 Points: 1,728 Location: USA
|
Hi Use the On Progress event in javascript to update your field. Dont make it hidden at first - make it a text box so you can see its working. Then pick it up server side! http://www.aspnetmedia.com
|
|
Rank: Newbie Groups: Member
Joined: 5/14/2010 Posts: 9 Points: 27 Location: USA
|
Now I have this:
ASPNetMedia.FlashVideo(\"FlashVideoLeft\").OnProgress = function(object, position){ var txt=document.getElementById("txtPosition"); txt.value=position; }
It still isn't working. Can you point me in the right direction?
|
|
Rank: Administration Groups: Administration
Joined: 7/26/2007 Posts: 676 Points: 1,728 Location: USA
|
Hi Is there a javascript error in your error console?? ASPNetMedia.FlashVideo(\"FlashVideoLeft\")<< you dont need the backslashes!!! http://www.aspnetmedia.com
|
|
Rank: Newbie Groups: Member
Joined: 5/14/2010 Posts: 9 Points: 27 Location: USA
|
Actually, the backslashes are not there. This is my code that is not working: ASPNetMedia.FlashVideo("FlashVideoLeft").OnProgress = function(object, position){ var txt=document.getElementById("txtPosition"); txt.value=position; }
|
|
Rank: Newbie Groups: Member
Joined: 5/14/2010 Posts: 9 Points: 27 Location: USA
|
Do you have a sample of where this is working that I can look at?
|
|
Rank: Administration Groups: Administration
Joined: 7/26/2007 Posts: 676 Points: 1,728 Location: USA
|
The SDK (from your downloads page) has a page with examples of all the JavaScript API functions. http://www.aspnetmedia.com
|
|
Rank: Newbie Groups: Member
Joined: 5/14/2010 Posts: 9 Points: 27 Location: USA
|
I am looking specifically for an example of where the OnProgress event is used to populate a ASP.NET control with the position. I don't see it anywhere in the SDK, the examples are very limited. Any thoughts on why the procedure is not working?
|
|
Rank: Administration Groups: Administration
Joined: 7/26/2007 Posts: 676 Points: 1,728 Location: USA
|
No idea. Thts why i asked if there were errors in your error console: How about this: ASPNetMedia.FlashVideo("FlashVideoLeft").OnProgress = function(object, position){ alert(position); } http://www.aspnetmedia.com
|
|
Rank: Newbie Groups: Member
Joined: 5/14/2010 Posts: 9 Points: 27 Location: USA
|
Yes, that code works to display the position in a messagebox. What I need, however is to read that value from ASP.NET and I can't read it out of a messagebox. I need an example of whee the value is successfully being written to a ASP.NET control that I can read out from the server side.
Thanks, Brian
|
|
Rank: Newbie Groups: Member
Joined: 5/14/2010 Posts: 9 Points: 27 Location: USA
|
I finally got it. Apparently, in order for the Javascipt to write the value to the textbox, it needs to be injected at runtime by getting the Textbox's ClientID from the web form. The working code is below:
StringBuilder strScript = new StringBuilder(); strScript.AppendLine("<script>ASPNetMedia.FlashVideo(\"FlashVideoLeft\").OnProgress = function(object, position){"); strScript.AppendLine("document.getElementById('" + this.txtPosition.ClientID + "').value=position;}</script>");
Page.ClientScript.RegisterStartupScript(this.GetType(), "JavaScript", strScript.ToString() , false);
Thanks.
|
|
Rank: Administration Groups: Administration
Joined: 7/26/2007 Posts: 676 Points: 1,728 Location: USA
|
Excelent! Yeah - use the clientid! http://www.aspnetmedia.com
|
|
|
Guest |