Share This!

Wednesday, February 29, 2012

Using Page Properties in ASP.net

 This tutorial will show you how to create and use a page property in ASP.NET.  In this example, the requirement is to randomly select a flash video and embed it into a web page.

First, we create a page property in the code-behind page (C# file).


public partial class _Default : System.Web.UI.Page
{
    //name of the video we're showing.
    string thisvideo = "";

    //this is the read-only property. In the page it'll be seen as <%=VideoUrl %>
    public string VideoUrl
    {
    //it only has a 'get' no set.
        get
        {
            return "SomeString";
        }
    }

Now we embed the property in the HTML like this...


            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300"
                id="FLVPlayer">
                <param name="movie" value="flv/FLVPlayer_Progressive.swf" />
                <param name="quality" value="high" />
                <param name="wmode" value="opaque" />
                <param name="scale" value="noscale" />
                <param name="salign" value="lt" />
                <param name="FlashVars" value="&amp;MM_ComponentVersion=1&amp;skinName=flv/Clear_Skin_1&amp;streamName=<%=VideoUrl %>&amp;autoPlay=true&amp;autoRewind=true" />
                <param name="swfversion" value="8,0,0,0" />
                <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
                <param name="expressinstall" value="js/expressInstall.swf" />
                <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
                <!--[if !IE]>-->
                <object type="application/x-shockwave-flash" data="flv/FLVPlayer_Progressive.swf"
                    width="400" height="300">
                    <!--<![endif]-->
                    <param name="quality" value="high" />
                    <param name="wmode" value="opaque" />
                    <param name="scale" value="noscale" />
                    <param name="salign" value="lt" />
                    <param name="FlashVars" value="&amp;MM_ComponentVersion=1&amp;skinName=flv/Clear_Skin_1&amp;streamName=<%=VideoUrl %>&amp;autoPlay=true&amp;autoRewind=true" />
                    <param name="swfversion" value="8,0,0,0" />
                    <param name="expressinstall" value="js/expressInstall.swf" />
                    <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
                    <div>
                        <h4>
                            Content on this page requires a newer version of Adobe Flash Player.</h4>
                        <p>
                            <a href="http://www.adobe.com/go/getflashplayer">
                                <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
                                    alt="Get Adobe Flash player" /></a></p>
                    </div>
                    <!--[if !IE]>-->
                </object>
                <!--<![endif]-->
            </object>
Ok, this seems needlessly complicated, but note the green text.  This is the page property we created in the code behind page...



Bryan Valencia is a contributing editor and founder of Visual Studio Journey.  He owns and operates Software Services, a web design and hosting company in Manteca, California.

Thursday, February 16, 2012

Open a Web Page from C#.NET

How to easily open a web page from your C# App.

System.Diagnostics.Process.Start("http://209software.com/");



Bryan Valencia is a contributing editor and founder of Visual Studio Journey.  He owns and operates Software Services, a web design and hosting company in Manteca, California.

Tuesday, February 14, 2012

Easy Javascript Magnifying Glass

I had to do a report listing emails sent from my system... the report was going to be huge with all the text from the emails included, so I wrote a quick mouseover magnifier that bumped up the size of the text.

Behold.
<div onmouseover="this.style.fontSize='1em'" onmouseout="this.style.fontSize='.5em'">


The fun parts of this that matter are...
onmouseover="this.style.fontSize='1em'" 
and 
onmouseout="this.style.fontSize='.5em'"

These, when applied to the div, will cause the text in the grid to change size accordingly.

Sample - mouse over this to expand:
I had to do a report listing emails sent from my system... the report was going to be huge with all the text from the emails included, so I wrote a quick mouseover magnifier that bumped up the size of the text.

Behold.
<div onmouseover="this.style.fontSize='1em'" onmouseout="this.style.fontSize='.5em'">


The fun parts of this that matter are...
onmouseover="this.style.fontSize='1em'" 
and 
onmouseout="this.style.fontSize='.5em'"

These, when applied to the div, will cause the text in the grid to change size accordingly.


Bryan Valencia is a contributing editor and founder of Visual Studio Journey.  He owns and operates Software Services, a web design and hosting company in Manteca, California.

Contact Us

Name

Email *

Message *