Decrease Font Size
Increase Font Size
   BLOG

Flex Builder cannot locate the required version of the Flash Player. You might need to install Flash Player 9 or reinstall Flex Builder. Do you want to try to run your application with the current version

by bryian 31. July 2009 19:30

Flex Builder cannot locate the required version of the Flash Player. You might need to install Flash Player 9 or reinstall Flex Builder. Do you want to try to run your application with the current version?

Flex Builder cannot locate the required version of the Flash Player. You might need to install Flash Player 9 or reinstall Flex Builder. Do you want to try to run your application with the current version?

C:\Program Files\Mozilla Firefox\plugins\NPSWF32.dll

Flex Builder cannot locate the required version of the Flash Player. You might need to install Flash Player 9 or reinstall Flex Builder. Do you want to try to run your application with the current version?

Firefox Flash Player error

I'm using Adobe Flex Builder 3.0. My default web browser was set to Firefox and went I tried to debug my code, I received the above error.

Solution for Firefox Browser:

  1. Uninstalling the current version of Flash Player by using the Adobe Flash Player uninstaller

  2. In my case, I downloaded this file Download the Windows Flash Player 10 Plugin content debugger (for Netscape-compatible browsers) (EXE, 2.09 MB) from Adobe.com . After the installation, try to debug the Flex application again, the warning dialogue box should not appear.

Internet Explorer Flash Player error

I set my default browser to Internet Explorer and debug my Flex application, I received the above error.

Solution for Internet Explorer Browser:

  1. Uninstalling the current version of Flash Player by using the Adobe Flash Player uninstaller (Skip this step if you already gone through Solution for Firefox Browser)

  2. Download the Windows Flash Player 10 ActiveX control content debugger (for IE) (EXE, 2.12 MB) from Adobe.com . After the installation, try to debug the Flex application again, the warning dialogue box should not appear.

Tags: , ,

Other

VS 2008 change default browser for ASP.NET MVC

by bryian 30. July 2009 18:03

Visual Studio 2008 change default browser MVC

VS 2008 change default browser ASP.NET MVC

Setting a Default Browser for Visual Studio 2008

If we do a quick search on Google "How to change the default browser in Visual Studio 2008?"

We’ll find many tips that say something like

  1. "Right click on any .aspx page or on a folder" in solution explorer and select Browse with...,

  2. Choose your Browser from the list

  3. Hit the Set as Default button

  4. and click the Browse button to start browsing or cancel to exit the dialogue box.

But, we will not get the "Browse with…" option by simply click on any folder or .aspx other than the Default.aspx page in ASP.NET MVC project.

So, when working on any ASP.NET MVC application, right click on the Default.aspx page to get the "Browse with…" option.

Tags: , ,

ASP.NET

Incorrect syntax near PIVOT. You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel

by Admin 29. July 2009 15:02

Msg 325, Level 15, State 1, Line 9 Incorrect syntax near 'PIVOT'. You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel.

Incorrect syntax near 'PIVOT'. You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel.

Why I’m getting this error?
The PIVOT command is not available for SQL Server 2000. When we upgrade the SQL Server 2000 instance to SQL Server 2005, the database COMPATIBILITY_LEVEL remain in 80 until we change it manually.

Solution:

If you are running SQL 2005
EXEC sp_dbcmptlevel 'myDatabaseName', 90

If you are running SQL 2008
EXEC sp_dbcmptlevel 'myDatabaseName', 100

New Syntax as of 02/26/2009:

ALTER DATABASE database_name 
SET COMPATIBILITY_LEVEL = { 80 | 90 | 100 }

http://msdn.microsoft.com/en-us/library/bb510680.aspx

Tags: , , ,

SQL

How to develop a Simple Text Scroller custom server control in ASP.NET

by Admin 21. July 2009 19:43

Simple Vertical Text Scroller ASP.NET Server control

Simple Vertical Text Scroller with Button ASP.NET 2.0 Server control

How to develop a Simple Text Scroller custom server control in ASP.NET

Step by step on how to create a custom server control in ASP.NET 2.0

Description:

Couple years ago, I was looking for a simple text scroller application to replace our text scoller that was based on Java and I found Cross Browser marquee II on dynamicdrive.com. I have modified it to tailor my requirement (http://download.ysatech.com/message-scroller/). The main modification I made to the scroller was the addition of two buttons that controlled the flow of the vertical scroll content. Recently, I did a quick search on Google and found out that handful (50+) of websites were still using this application. Below are the few of them.

Check it out:

http://cherryle.win.aplus.net/index.asp

http://www.hydroqual.com/

http://www.sabugacenter.com/

http://www.opcfoundation.org/

http://www.mmtv.co.za/index.htm

Moving forward, I have converted this application to ASP.NET custom server control. Now, the ASP.NET developers can drag and drop the control to the page without copy and paste between the web applications. Below is a brief tutorial on how I have accomplished this. Hope this tutorial will give someone an idea on how to create custom server control.

Download the original application/ script

cmarquee2.htm

Note:

I have broken the cmarquee2.htm page into three different sections, namely Style Sheet, JavaScript and static HTML elements/ tags.

Create Class Library

  1. Open VS 2005/2008. Go to File, New, Project, Visual C# and select Class Library template and fill up the required field.

    Create New Project

  2. Rename the class1.cs to TextScroller.cs

Adding Style Sheet

Right click the project, Add, New Item, Visual C# Project Items, Select Style Sheet from the available templates. Name it TextScroller.css. Extract all the Style Sheet from cmarquee2.htm into TextScroller.css

Adding JavaScript

Right click the project, Add, New Item, Visual C# Project Items, Select Jscript File from the available templates Name it TextScroller.js. Extract all the JavaScript from cmarquee2.htm into TextScroller.js

Add New Item

Adding New Folder

Right click the MyTextScroller project, Add, New Folder, rename the folder to images. Place all the images in this folder.

Adding References

Right click on the MyTextScroller project, Add Reference. In the .NET tab locate the System.Web component name, select it and click Ok

Adding Reference

The structure of the project should look like the picture from below if you follow all the above step correctly.

 

Structure

Embedding the Resources

Right click one of the images, select Properties, and change the Build Action value from Content to Embedded Resource. Repeat the same step for all the other images.

 Embed Images

Repeat the above step for the JavaScript and Style Sheet.

Double click the AssemblyInfo.cs. Add the following to the bottom of the file.

 
[assembly: System.Web.UI.WebResource("MyTextScroller.TextScroller.css", "text/css")]
[assembly: System.Web.UI.WebResource("MyTextScroller.TextScroller.js", "text/javascript")]
[assembly: System.Web.UI.WebResource("MyTextScroller.images.nav-arrow-down-hover.gif", "image/gif")]
[assembly: System.Web.UI.WebResource("MyTextScroller.images.nav-arrow-down.gif", "image/gif")]
[assembly: System.Web.UI.WebResource("MyTextScroller.images.nav-arrow-up-hover.gif", "image/gif")]
[assembly: System.Web.UI.WebResource("MyTextScroller.images.nav-arrow-up.gif", "image/gif")]

Note:

Default Namespace

The syntax - [assembly: System.Web.UI.WebResource("Default Namespace.File Location.File Name", "Type")]

Example 1

My Default Name Space is MyTextScroller

My JavaScript File name is TextScroller.js

And I’ll end up having this line in my AssemblyInfo.cs

[assembly: System.Web.UI.WebResource("MyTextScroller.TextScroller.js", "text/javascript")]<br /><br />

Example 2

My Default Name Space is MyTextScroller

My image is in images folder

My image name is nav-arrow-down-hover.gif

And I’ll end up having this line in my AssemblyInfo.cs

[assembly: System.Web.UI.WebResource("MyTextScroller.images.nav-arrow-down.gif", "image/gif")]<br /><br />

TextScroller.cs

The TextScroller.cs will hold all the static HTML elements from the cmarquee2.htm. Please look at the code, is pretty straight forward. Here is a brief explanation.

Add design-time attributes to provide custom metadata that will be used to display the control in the visual designer at design time

[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal), 
AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal), 
ParseChildren(true, "innerHTML"), 
DefaultProperty("innerHTML"), 
ToolboxData("<{0}:TextScroller runat=\"server\"> </{0}:TextScroller>")]

Additional Reading/ Information

The ToolboxData attribute specifies the default tag generated for the TextScroller control when it is dragged from the Toolbox into a page at design time.

ParseChildren

AspNetHostingPermission

//Properties to adjust the width and height of the DIV

    
     #region Public Properties

        private Unit width = Unit.Pixel(260);
        public override Unit Width
        {
            get { return width; }
            set { EnsureChildControls(); width = value; }
        }

        private Unit height = Unit.Pixel(160);
        public override Unit Height
        {
            get { return height; }
            set { EnsureChildControls(); height = value; }
        }

// property to set the content of the Text Scroller
private string _innerHTML = "Your Content here";

        [   Browsable(true), //display this property in designer
            Category("Appearance"),
            DefaultValue("Your Content Here"),
            Description("The Content to Display."),
            Localizable(true),
            PersistenceMode(PersistenceMode.InnerDefaultProperty) ]
        public virtual string innerHTML
        {
            get
            {
                return _innerHTML;
            }
            set
            {
                EnsureChildControls(); _innerHTML = value; 
            }
        }	
        #endregion

Working with Web Resources in ASP.NET 2.0

 

Images:

Image myImage = new Image();
ClientScriptManager cs = Page.ClientScript;
Type rsType = this.GetType();
myImage.ImageUrl = cs.GetWebResourceUrl(rsType, "MyTextScroller.images.nav-arrow-up.gif")

JavaScript:

Type rsType = this.GetType();
this.Page.ClientScript.RegisterClientScriptInclude(
                        rsType, "TextScroller_Script_Name",
                        Page.ClientScript.GetWebResourceUrl(rsType, " MyTextScroller.TextScroller.js"));

Style Sheet:

   
Type rsType = this.GetType();     
string csslink = @"<link rel='stylesheet' type='text/css' href='" + Page.ClientScript.GetWebResourceUrl(rsType, "MyTextScroller.TextScroller.css") + "' />";
LiteralControl include = new LiteralControl(csslink);
this.Page.Header.Controls.Add(include);

//using the embeded JavaScript and Style Sheet

   
        protected override void OnInit(EventArgs e)
        {
            //Get the name of the Web Resource.
            base.OnInit(e);

            this.Page.ClientScript.RegisterClientScriptInclude(
                        this.GetType(), "TextScroller",
                        Page.ClientScript.GetWebResourceUrl(this.GetType(),
                        "Scroller.TextScroller.js"));

            // create the style sheet control and put it in the document header
            string csslink = @"<link rel='stylesheet' type='text/css' href='" + Page.ClientScript.GetWebResourceUrl(this.GetType(), "Scroller.TextScroller.css") + "' />";
            LiteralControl include = new LiteralControl(csslink);

            this.Page.Header.Controls.Add(include);

        }

        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
        }

//write the output to the page in the cmarquee2.htm page
        protected override void Render(HtmlTextWriter output)
        {
            EnsureChildControls(); 

            output.Write(GenerateDiv());
        }

//create all the HTML Tag elemets
        private string GenerateDiv()
        {
            //see attached code
        }
    }
}

Individualizing the Control: Add a custom toolbox icon for the control

  1. Create an icon from any of the links below. This is free.

    genfavicon

    dynamicdrive

  2. What is the name of your class? For instance my class name is TextScroller

    public class TextScroller : WebControl, INamingContainer
    

    Named the icon TextScroller.ico. Place it in the project root directory and change the Build Action to Embeded Resource

Embed Icon

Adding the Control to the Toolbox

Go to View, Toolbox, Right click any place in the Toolbox, Add Tab, I name it MyTextScroller.

Right click MyTextScroller, Choose Items, .NET Framework Components Tab, Browse, find the MyTextScroller.dll, click Ok.

You should see the custom icon next to the control instead of the default icon.

Custom Icon

How to test it?

Add Refenence

  1. Right click on the solution, Add, New Web Site, ASP.NET Web Site/ ASP.NET AJAX-Enabled Web Site

     Add New WebSite

  2. Right click the TestMyTextScroller, Add References, Project Tab, MyTextScroller project, Ok

     Add New WebSite

Adding the Control to the Toolbox

  1. Go to View, Toolbox, Right click any place in the Toolbox, Add Tab, I name it MyTextScroller.

  2. Right click MyTextScroller, Choose Items, .NET Framework Components Tab, Browse, find the MyTextScroller.dll, click Ok.

    Custom Icon

  3. Drag the TextScroller to the Default.aspx. Try one of the following

   
<cc1:TextScroller ID="TextScroller1" runat="server" Height="100px">
		My test content here. <br />
		<a target="_blank" href="http://blog.ysatech.com">My Blog</a> <br />
		More text here….
      </cc1:TextScroller>

or

   
protected void Page_Load(object sender, EventArgs e)
    {
         TextScrollerContent();
    }

    internal void TextScrollerContent()
    {
        StringBuilder sbContent = new StringBuilder(string.Empty);
        
        sbContent.Append("My test content here. <br />");
        sbContent.Append("<a href=\"http://blog.ysatech.com\">My Blog</a> <br />");
        sbContent.Append("More text here…");    
      
        TextScroller1.innerHTML = sbContent.ToString();
    }

You should see something like below:

Results

Note:

Do not use any custom server control from any unknown sources that have JavaScript embedded to it. Go through all the JavaScript and make sure that no potential malicious scripts embedded in it.

Next improvement:

  1. Support multiple instances, currently this version work only with one instance of the TextScroller on the same page

  2. Allow user to change the image button during design time

Conclusion:

Here are the lists of items we have covered in this article:

  1. How to create Custom Server Control

  2. How to add Web reference

  3. How to embed resources

  4. How to add design-time attributes

  5. How to access embedded Resource

  6. How to include custom toolbox icon

  7. How to add custom server control to the Toolbox

  8. How to test the new control

Download

References:

http://aspalliance.com/726

http://www.asp.net

http://www.dynamicdrive.com/dynamicindex2/cmarquee2.htm

http://www.codeproject.com/

http://msdn.microsoft.com/en-us/library/system.web.ui.control.ensurechildcontrols.aspx

http://msdn.microsoft.com/en-us/library/system.web.aspnethostingpermission.aspx

http://ondotnet.com/pub/a/dotnet/excerpt/progaspdotnet_14/index2.html

http://msdn.microsoft.com/en-us/library/system.web.ui.parsechildrenattribute.aspx

http://support.microsoft.com/kb/910442