| Daniel's profileDaniel Benedykt Personal...PhotosBlogLists | Help |
|
16 June Watch TV for freeWatch TV from Uruguay or from around the world for free... http://wwitv.com/portal.htm?http://wwitv.com/television/218.htm --> Uruguay Channels http://wwitv.com/portal.htm?http://wwitv.com/television/index.html --> All Channels 31 May Check your trip before you fly...Before you fly, you can check your trip, and see all the reservations. (You need the reservation code and last name of the passanger) 23 May The Webby AwardsSee this year nominees and winners of the Webby Awards http://www.webbyawards.com/webbys/current.php My favorite .... www.google.com ... winner of the Best Navigation/Structure and the Best Practices awards 17 May Confirm deletes in datagridIntroduction ASP.NET DataGrid allows you to provide select, edit, cancel and delete buttons. These buttons trigger corresponding events on the server side. These buttons are nothing but button controls (link button or push button) with CommandName property set to select, update, cancel or delete. In this article we will focus on delete command alone. Many times we need to get confirmation from the user about deletion of the record. DataGrid do not provide any inbuilt way to do that. We will see how to prompt the user to confirm the delete using JavaScript. The web formWe will create a simple web form that contains a DataGrid which in turn is bound to the Employee table from Northwind database. The grid has a column Delete that triggers the DeleteCommand event handler. When the user clicks on the Delete button he will be prompted for confirmation. If he clicks on ok the form is posted as usual else the form will not be posted. The task of prompting the user is carried out via client side JavaScript. The Delete buttonIf you are using VS.NET you can easily add Delete button using the property builder. Note however that this adds a ButtonColumn to the grid. In order to add javascript to a client side event you have to use Attributes collection of the control. The button column do dot have an ID attribute and hence can not be used for this purpose. Hence, we need to use template column as shown below. <asp:DataGrid id="DataGrid1" runat="server"> <Columns> <asp:TemplateColumn> <ItemTemplate> <asp:LinkButton id="cmdDel" runat="server" Text="Delete" CommandName="Delete" CausesValidation="false"> </asp:LinkButton> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid>Next we need to add the javascript to each and every Delete link button (one per row). We will do that in ItemDataBound event handler. Private Sub DataGrid1_ItemDataBound (ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles DataGrid1.ItemDataBound Dim l As LinkButton If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then l = CType(e.Item.Cells(0).FindControl("cmdDel"), LinkButton) l.Attributes.Add("onclick", "return getconfirm();") End If End SubHere we check whether the item (row) is of type Item or AlternatingItem. We then add DHTML OnClick event handler that calls a client side function getconfirm(). The Confirmation JavaScript functionThe getconfirm function looks like this: function getconfirm() { if (confirm("Do you want to delete record?")==true) return true; else return false; }This function displays a javascript confirmation dialog to the user. If user clicks on Ok the function returns true and the form is posted back as usual. If user clicks on cancel it returns false indicating event cancellation. This will cancel the postback of the form. I hope it was interesting. See you soon. 14 May Solex - Web application testing with eclipseSolex is a Web application testing tool built as a plug-in for the Eclipse IDE. It provides functions to record a client session, adjust it according to various parameters and replay it later typically in order to ensure non regression of the application's behaviour (with stress testing capabilities being added at a later stage).
http://sourceforge.net/projects/solex/
http://solex.sourceforge.net/ 10 May DeKlaritDeKlarit is the data modeling and code generation tool that enables you to concurrently generate and maintain the data model, the data access and business logic layers of your .NET-connected applications. The DeKlarit Add-ins provide a complementary toolset to generate from components to complete presentation or web services layers. |
|
||
|
|