Update Panel with Update Progress

by pmcgann 8. May 2012 21:58

This is a simple example of showing a loading image while an update panel is waiting to load.

Go to this site and generate a loading image : Ajax Image Generator

Then add an update progress control to your page where the update control is and set the AssociatedUpdatePanelID to that of your update panel.

Inside the update progress add the progress template and then insert the image that you generated at the previous site.

Below is a example of this:

<asp:UpdatePanel ID="up_controls" runat="server">

            <ContentTemplate>

                <asp:PlaceHolder ID="ph_controls" runat="server"></asp:PlaceHolder> 

            </ContentTemplate>

        </asp:UpdatePanel>

        <asp:UpdateProgress AssociatedUpdatePanelID="up_controls" ID="up_progress" runat="server">

            <ProgressTemplate>

                <div class="form-content">

                    <p>

                        <img src="images/ajax-loader.gif" alt="Loading" />

                    </p>

                </div>

            </ProgressTemplate>

        </asp:UpdateProgress>

Tags:

Ajax | ASP.Net | VB.Net | Visual Studio 2008 | Tip and Tricks

Validating against Web Content Accessibility Guidelines

by pmcgann 8. May 2012 21:36

If you need to validate a site design against Web Content Accesibility Guidelines (WCAG). Visual Studio has a nice feature that you can turn on and it will validate your markup for you.

To enable this right click on the project and go to start options.

In the left panel select 'Build' then check the checkboxes that read:

  • include accessibility validation when building page.
  • include accessibility validation when building web.

 

See the image below for an illustration.

Tags:

ASP.Net | Visual Studio 2008 | Accessibility | Tip and Tricks

Migration from MySQL to SQL Server

by pmcgann 3. May 2012 22:29

Often when working with various companies they may have an existing database and may require that the existing data be imported from a mysql database to mssql server database. The below article is a good starting point and outlines some points to take into consideration.

MySQL to SQL Server Conversion Tutorial

Tags:

Hosting | SQL Server | Windows 2003 Server

Issue javascript click event with hidden fields

by pmcgann 6. January 2012 19:51

While working on a recent project I had an issue where, when I called a click event through javascript the event would not fire and click the element I wished to click below is the function I had for this:

<script type="text/javascript">

     function select(val) {

       document.getElementById(val).click()

     }
</script>

Because the elements I was working with are hidden on the page the javascript would not fire so I replaced the above with the one below:

<script type="text/javascript">

        function select(val) {

           document.getElementById(val).setAttribute("class", "selected");
           var fireOnThis = document.getElementById(val);
           if(document.createEvent){
           var evObj = document.createEvent('MouseEvents');
           evObj.initEvent('click', true, false);
           fireOnThis.dispatchEvent(evObj);
           } else if(document.createEventObject){
           var evObj = document.createEventObject();
           fireOnThis.fireEvent('onclick',evObj);
           }     
     }
</script>

Hope this helps anyone with a similiar problem.

Tags:

Short youtube urls not working with prettyphoto

by pmcgann 4. November 2011 00:59

This is a simple solution to help over come issues with users entering the short url's for youtube videos, which isn't compatibile with many jquery libraries out there.

Basically this function detects wether the url entered is a short url and if so re-writes the url to the long version.

Public Function fun_FormatYouTubeUrl(ByVal Url As String) As String

        Dim value As String = String.Empty

        Try
            If InStr(Url, "http://youtu.be/", CompareMethod.Text) Then
                value = "http://www.youtube.com/watch?v=" & Replace(Url, "http://youtu.be/", "")
            Else
                value = Url
            End If

        Catch ex As Exception

        End Try

        Return value

    End Function 

 No more problems with prettyphoto not working with youtube url's.

 

Tags:

Issue when editing CuteEditor using Safari Browser

by pmcgann 21. October 2011 21:37

This is one I came across while working on a recent site.

Whenever you edited text through the cuteeditor in safari it was added this line of code:

@import url(http://localhost/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);

To overcome this I updated the cuteeditor files and this had no effect.

It wasn’t until I updated the dll’s that the issue is resolved.

Tags:

Should You Use Alt or Title Attribute to Describe Images

by pmcgann 9. September 2011 19:42

If you're even slightly familiar with HTML language, you know about the image tag <IMG> that is used to display pictures in web pages. This tag supports two similar attributes – TITLE and ALT – that are both supposed to describe the image in words.

These attributes are important as they impact image search rankings but confusing too because we often don't know whether to use TITLE or ALT or both attributes when describing images.

Luckily, the rule is pretty simple - always add the ALT attribute to your images but include the TITLE attribute only if the image is a link. I have tried to illustrate this with an image of a McDonald's Burger.

 

Case A: The burger image is not linking anywhere so we just use the ALT attribute describing the image.

Case B: The burger image links to the nutrition section on the McDonald's website so we also include a TITLE attribute that gives the visitor an idea about the linked page. Note that ALT attribute continues to describe the image as in Case A.

This point is made in the Google SEO Guide [PDF] as well though with a slight error. It says "if you do decide to use an image as a link, filling out its alt text helps Google understand more about the page you're linking to." I think that "alt text" should be read as "title text" according to John Mueller's advice.

Tags:

Validate Email Host

by pmcgann 4. June 2011 09:58

It is quite easy to by-pass standard email validation something as simple as me@me.com is a valid email address. To add some extra validation we can use sockets to validate the email address host. The following function will take validate the email address hostname.

 Public Shared Function fun_ValidateEmailHost(ByVal Email As String) As Boolean

        Try
            Dim host As String() = Email.Split("@")
            Dim hostname As String = host(1)

            Dim soc As Socket
            Dim entry As IPHostEntry = Dns.GetHostEntry(hostname)
            Dim EndPoint As IPEndPoint = New IPEndPoint(entry.AddressList(0), 25)
            soc = New Socket(EndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
            soc.Connect(EndPoint)

            Return True

        Catch ex As Exception

            Return False

        End Try


    End Function

Tags:

ASP.Net | Security | VB.Net

Create A Task List For Project

by pmcgann 28. May 2011 00:03

Whenever you are build projects etc. Often it is good to have a list of Tasks to Complete to remind yourself which tasks need completed.

In Visual Studio you can create a task list to remind yourself of tasks to complete on a project.

To add a Task simple insert a comment as shown below.

'TODO - Update Product

Then in visual studio open the task list by opening View > Task List (Ctrl + T) and change the DropDown to Comments and you should see a list of Tasks to complete on the project.

Other Comments also include HACK and UNDONE.

http://msdn.microsoft.com/en-us/library/zce12xx2(v=vs.80).aspx

Tags:

Download and Save Image Using URL

by pmcgann 4. April 2011 18:12

If you need to download images across sites try using this function.

Public Function getImageByUrl(ByVal url As String, ByVal filename As String) As Boolean

        Dim response As WebResponse = Nothing
        Dim remoteStream As Stream = Nothing
        Dim readStream As StreamReader = Nothing
        Try
            Dim request As WebRequest = WebRequest.Create(url)
            If request IsNot Nothing Then
                response = request.GetResponse()
                If response IsNot Nothing Then
                    remoteStream = response.GetResponseStream()

                    readStream = New StreamReader(remoteStream)

                    Dim img As System.Drawing.Image = System.Drawing.Image.FromStream(remoteStream)

                    If img Is Nothing Then
                        Return False
                    End If

                    img.Save(System.Web.HttpContext.Current.Server.MapPath("\databaseimages\") & filename, System.Drawing.Imaging.ImageFormat.Jpeg)
                    img.Dispose()
                End If
            End If
        Finally
            If response IsNot Nothing Then
                response.Close()
            End If
            If remoteStream IsNot Nothing Then
                remoteStream.Close()
            End If
            If readStream IsNot Nothing Then
                readStream.Close()
            End If
        End Try

        Return True
    End Function

Tags:

ASP.Net | VB.Net

 

Posts By Date

Log in