how to set a object param in code

A

Aussie Rules

Hi,

I have the Windows media object placed on a web page.

Since its not a .net component (its a com object) I have placed the code in
the html source of the page. The problem I am having is that I get the url
of the video file i want to play in the asp.net code (form_load event). How
do I pass this value into the html...

Ie :

<html>
<html>
<object id=msnVwmp class=msnVa
classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 style="width: 141px;
height: 141px">
<param name=uiMode value=full>
<param name=enableContextMenu value=false>
<param name=stretchToFit value=false>
<param name=windowlessvideo value=false>
<param name=url value="">
</object>
</htm>

In my ASPX Code behind file:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load

strFileName = http://myurl.com/sample.avi

End Sub





Somehow I need to get the strFileName in my code behind file, into the param
url value field....



Thanks
 
W

Walter Wang [MSFT]

Hi Aussie,

To set the media player's property from server-side code, you have two
options:

1) Declare a public property to return the video url:

public string VideoUrl
{
get
{
return "http://localhost/1.avi";
}
}

Then modify the WebForm:

<object id=msnVwmp class=msnVa
classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 style="width:
141px;
height: 141px">
<param name=uiMode value=full>
<param name=enableContextMenu value=false>
<param name=stretchToFit value=false>
<param name=windowlessvideo value=false>
<param name=url value="<%= VideoUrl %>">
</object>

This way, the generated media player's declaration will get updated url
property value from server-side code.

2) Register a startup javascript function to control the media player:

protected void Button1_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(GetType(), "mp",
"form1.msnVwmp.url='http://mysite/1.avi';", true);
}

Hope this helps. Please feel free to post here if anything is unclear.

Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Aussie Rules

Sorry for the most basic of basic questions...

Do i put the public string... code into a class of its own, or in the code
behind file?

Thanks
 
W

Walter Wang [MSFT]

Hi Aussie,

If you are using Single-File Pages, you can use embedded server-side code
block:

<script runat="server">
public string VideoUrl
...
</script>

In a single-file page, the markup, server-side elements, and event-handling
code are all in a single .aspx file. When the page is compiled, the
compiler generates and compiles a new class that derives from the base Page
class or a custom base class defined with the Inherits attribute of the @
Page directive.

If you are using Code-Behind Page Model, you need to put the function in
the code file. The code file contains a partial class. When the page is
compiled, ASP.NET generates a partial class based on the .aspx file; this
class is a partial class of the code-behind class file. The generated
partial class file contains declarations for the page's controls. This
partial class enables your code-behind file to be used as part of a
complete class without requiring you to declare the controls explicitly.

References:
==========
#ASP.NET Web Page Code Model
http://msdn2.microsoft.com/en-us/library/015103yb.aspx

#ASP.NET Page Class Overview
http://msdn2.microsoft.com/en-us/library/ms178138.aspx

#Code Render Blocks
http://msdn2.microsoft.com/en-us/library/k6xeyd4z.aspx

#partial (C# Reference)
http://msdn2.microsoft.com/en-us/library/wbx7zzdd.aspx

Hope this helps. Please feel free to post here if anything is unclear.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

Walter Wang [MSFT]

Hi Aussie,

Just noticed your another post about "public string", I'm sorry I didn't
notice that you're coding the web application in VB.NET.

Anyway, the reference articles in my previous post will still be useful for
you to understanding the "Code Render Blocks". If you need anything else,
please feel free to post here.

For the VB.NET syntax of the property I suggested, you can use:

Public ReadOnly Property VideoUrl()
Get
Return "http://localhost/1.avi"
End Get
End Property

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top