Dynamic rich media component for ASP.Net Flash, Video, Audio, FlashVideo and ToolTip / Balloon Help controls for C# and VB.Net
Welcome Guest Search | Active Topics | Members | Log In | Register

Trouble with GetPosition() from C# Options · View
bkyoun77
Posted: Friday, May 21, 2010 12:16:17 AM
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!
Jake
Posted: Friday, May 21, 2010 12:33:55 AM
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
bkyoun77
Posted: Friday, May 21, 2010 12:54:21 AM
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?
Jake
Posted: Friday, May 21, 2010 12:59:20 AM
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
bkyoun77
Posted: Friday, May 21, 2010 1:01:03 AM
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;
}
bkyoun77
Posted: Friday, May 21, 2010 1:18:19 AM
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?
Jake
Posted: Friday, May 21, 2010 1:20:28 AM
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
bkyoun77
Posted: Friday, May 21, 2010 2:53:25 AM
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?
Jake
Posted: Friday, May 21, 2010 3:14:04 AM
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
bkyoun77
Posted: Friday, May 21, 2010 10:32:38 PM
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
bkyoun77
Posted: Friday, May 21, 2010 11:04:58 PM
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.
Jake
Posted: Saturday, May 22, 2010 1:17:37 AM
Rank: Administration
Groups: Administration

Joined: 7/26/2007
Posts: 676
Points: 1,728
Location: USA
Excelent!
Yeah - use the clientid!

http://www.aspnetmedia.com
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.