Using Mailto in ASP:HyperLink

So I wanted to add a mailto link in my code. I knew that it would be something to do with the asp:HyperLink control but was not sure how to use it. After a little testing I found this information out.

So I had pulled my email address from a SQL statement and wanted to add it to the control, this was my first attempt:

<asp:HyperLink ID="hlEmail" NavigateUrl="mailto:" Text='<%# Bind("Email") %>' runat="server"></asp:HyperLink>

This gave me a HyperLink but with a blank mailto, well that was no good. So next I got to thinking that I need to stick a Bind or Eval with the text on the NavigateUrl section:

<asp:HyperLink ID="hlEmail" NavigateUrl='mailto:<%# Bind("Email") %>' Text='<%# Bind("Email") %>' runat="server"></asp:HyperLink>

This gave me a link, but it do not work. Every time I clicked on the link nothing happened. Again I tried some more code and came up with the following:

<asp:HyperLink ID="hlEmail" NavigateUrl='<%# Bind("Email", "mailto:{0}") %>' Text='<%# Bind("Email") %>' runat="server"></asp:HyperLink>

This worked, so it was to do with formatting the string.  By using the in built string formatting options I was able to pass the Bind vale to the NavigateUrl parameter. Easy when you know how.

So I was looking for a SQL Browser to use with Oracle

I’ve been recently looking for a SQL Browser Tool to use with Oracle, but also wanted it to work with a few other databases that I work with, such as MS SQL, DB2 and My SQL.  So off to the internet I went and did some searching around. After a while I came across a product called RazorSQL and checked that it would work with the database that I required and with Windows 7, and it did!!  Great, so I downloaded the trial, installed and connected it to all the databases that I wanted.

I found the product really easy to use and some of the features are really good, some of which I would of only expected to find in a really expensive add-on by one of the original DB manufacturers. After the trial period was up I bought a RazorSQL registration and I’ve been using this ever since.  Great product!!

 

 

Putting a Media Code into your ASP.NET Code

Ever wanted to display a Windows Media file on your Web Page. Then here is the answer and it works for both Internet Explorer and Mozilla Firefox. First declare a variable at the top of your page for use later on. This way if you arrive to this page from another you can handle what Media file gets shown.

<script runat="server">
  Public mySrc As String = ""

  Sub Page_Load()
    mySrc = "video/Wildlife.wmv"
  End Sub
</script>

Next Place this code on your page where you wish to see the Media.

<object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="player" width="640" height="480">
  <param name="url" value="<%=mySrc %>" />
  <param name="src" value="<%=mySrc %>" />
  <param name="uiMode" value="mini" />
  <param name="autostart" value="true" />
  <param name="volume" value="50" />
  <!--[if !IE]>-->
  <object type="application/x-ms-wmp" data="<%=mySrc %>" width="640" height="480">
    <param name="src" value="<%=mySrc %>" />
    <param name="uiMode" value="mini" />
    <param name="autostart" value="true" />
    <param name="volume" value="50" />
  </object>
  <!--<![endif]-->
</object>

It’s as easy as that.

 

 

Delete Confirmation on a ASP.NET GridView

So I want something a little more than just the Default Delete option that you get with the GridView control. When you click this Delete button, your record just disappears and you’re left for a few moments thinking to yourself, “did I really want to delete that?”.  Well I thought I needed to find a method of being able to prompt the user for a confirmation before actually deleting the record.

After searching the web I came across a version that worked really well and was simple to implement, so I thought I would share it here.

      <asp:GridView
        ID="GridView1"
        DataSourceID="DataSource1"
        DataKeyNames="ID"
        AutoGenerateColumns="false"
        runat="server">
        <Columns>
        <asp:BoundField
          HeaderText="Record ID"
          DataField="ID"
          ReadOnly="true" />
        <asp:BoundField
          HeaderText="Movie Title"
          DataField="MOVIE" />
        <asp:CommandField
          HeaderText="Edit?"
          ButtonType="Button"
          ShowSelectButton="true"
          SelectText="Select" />
        <asp:TemplateField>
          <HeaderTemplate>
            Delete?
          </HeaderTemplate>
          <ItemTemplate>
            <asp:Button
              ID="btnDelete"
              OnClientClick="return confirm('Are you sure you want to delete this record?');"
              CommandName="Delete"
              Text="Delete"
              runat="server" />
          </ItemTemplate>
        </asp:TemplateField>
        </Columns>
      </asp:GridView>

Technorati Tags: ,,

How to Refresh GridView after Update on DetailsView

When using a master GridView with a details DetailView and an Insert or Update is performed at the DetailsView level the GridView does not refresh with the new values.  This one was bugging me for a while, but I finally found the answer. I knew that is was to do with the DataBind() on the GridView, but where and when did it need to be called.  The answer is to put the DataBind() on the DetailView’s  ItemUpdated  event.

  Private Sub DetailsView1_ItemUpdate(ByVal sender As Object, _
                                      ByVal e As DetailsViewUpdatedEventArgs) Handles DetailsView1.ItemUpdated
    GridView1.DataBind()
  End Sub

Technorati Tags: ,,

How do you Delete files Older than a given date?

So I got asked if I knew a way of deleting files from a folder that were older than a given date.  I knew this could be done with the Windows OS, bust just how. The Delete command itself is not good enough for the job, so it was time to write a batch file to do the job. I also thought why re-invent the wheel as someone else must have tried this so a quick search on the Internet and I found some information and put it all together. Here is my Batch file, just copy and paste into Notepad.exe and save as DELOLD.bat

   1: @ECHO OFF
   2: SET OLDERTHAN=%1
   3: IF NOT DEFINED OLDERTHAN GOTO SYNTAX
   4:  
   5: echo. >> ~~~FILES_TO_KEEP.TXT~
   6: for /f "tokens=*" %%a IN ('xcopy *.* /d:%1 /L /I null') do if exist %%~nxa echo %%~nxa >> ~~~FILES_TO_KEEP.TXT~
   7: for /f "tokens=*" %%a IN ('xcopy *.* /L /I /EXCLUDE:~~~FILES_TO_KEEP.TXT~ null') do if exist "%%~nxa" del "%%~nxa"
   8: del ~~~FILES_TO_KEEP.TXT~
   9:  
  10: GOTO END
  11:  
  12: :SYNTAX
  13: ECHO.
  14: ECHO USAGE:
  15: ECHO DELOLD mm-dd-yyyy
  16: ECHO   Where mm-dd-yyyy is the date prior to which you want to delete files.
  17: ECHO.
  18: ECHO EX: "DELOLD 10-17-2008" Deletes files older than October, 17 2008.
  19: GOTO END
  20:  
  21: :END

You need to enter the date in the given format of mm-dd-yyyy as the XCOPY command needs it this way. Place the batch file in the folder that you need to delete the files from and execute the batch file.

List Data Providers

Here is a small application that I wrote to check your OS for Data Providers currently Installed.  Download and UnZip, and then run the Setup.exe program. This should create a new folder called List Data Providers in your All Programs folder from your Start Bar. Click on the program and it should open up.

image

Click on the button labelled Providers and it will quickly check what you’ve got configured/installed on your OS. It should come back with a list that looks like this:

image