June 2nd, 2006

You are currently browsing the articles from TechToolBlog written on June 2nd, 2006.

Adding a Confirm Javascript PopUp to a ASP.NET GridView

The more and more I use the GridView control, the more I end up writing my own rather then using the DataBound columns because of the additional flexiblity you get when writing your own templates.

This time I ended up writing my own TemplateField because I need to add a confirm pop up to basically a “delete” command (it didn’t really delete the database record but in fact flagged it as a different type)… but you get the idea where this might come in handy. After all you don’t want users calling saying “Yeah, I just deleted something I didn’t mean to”. Instead you want to pop up a javascript box with a “Do you really want to do this…because I am not fixing it again!”

Unfortunetly the doesn’t offer you an onClientClick event, so this is my work around.

Here is the basic Javascript code to pop up a confirm button.

<SCRIPT LANGUAGE=”JavaScript”>

      function confirmSubmit() {

      var agree=confirm(“Do you really want to mark this prospect as in the database?”);

      if (agree)

       return true ;

      else

       return false ;

    }

    </SCRIPT>

Now in your GridView->Column Tag add a and your onClientClick attribute. This will call your Javascript function above and display a confirm popup to your users. You also must define a onClick event that points to a function that you will need to create for the server side processing of this request.

<asp:TemplateField>

    <ItemTemplate>

        <asp:Button ID=”btnCustomerExist”

        text=”customer exist”

        Runat=Server

        OnClick=”CustomerAlreadyExist”

        OnClientClick=”return confirmSubmit()”

        Width=”100″ />

   </ItemTemplate>

  </asp:TemplateField>

If the user clicks “OK” on the popup, you will need to handle the server side processing. I tend to write my own Data Access layer to handle Selects and Deletes so for me it is pretty straight forward from here, I call a function and pass in the unique id from the database.

Public Sub CustomerAlreadyExist(ByVal sender As Object, ByVal e As EventArgs)

        Dim ProspectID As Int32

 

        Dim btnRemoveProspect As Button = CType(sender, Button)

        Dim grdRow As GridViewRow = CType(btnRemoveProspect.Parent.Parent, GridViewRow)

        ‘Get ID

        ProspectID = grdRow.Cells(0).Text

        ‘Instant Class

        myAddProspect = New AddProspect()

        ‘Removes from Prospect Table

        myAddProspect.RemoveFromDatabase(ProspectID)

        ‘Refresh Gridview

        Page_Load(sender, e)

    End Sub

The End Result

Of course this won’t stop everyone from accidentally deleting users but it will stop 9/10.

Written by Tim on June 2nd, 2006 with 2 comments.
Read more articles on asp.net.



Vintage Microsoft Magazine Ads

I rumaged the internet to find these Microsoft print ads. I know their not Apple quality but still cool to see.

I never have really done anything with 16 bit software except hack an old King’s Quest Mod a long time ago, but I bet Microsoft tool is what I used ;)

This was an early ad for Windows 95 - I hope Microsoft fired that Marketing Company, this ad is horrible.

123 vs Excel, this might have been Microsoft’s first software war. I’m actually glad Excel won, I wasn’t a big fan of 123.

Flight Simulator This was No Doubt their best game for years, way a head of times. I played this for hours.

Remember when Wall Street liked Microsoft, Now their stock falls even when they exceed expectations.

Multiplan - This later became Excel for you kids out there. It was also Microsoft’s first GUI attempt.

Will Microsoft become the first to create the first truly mobile computer for personal use? Technology can really take us anywhere, as devices with a touch screen monitor can attest to. Who knows how far advanced computers, barcode scanners and business electronics can get!

Written by Tim on June 2nd, 2006 with 3 comments.
Read more articles on web 2.0 ish.