|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Pop-up Message BoxI have a DataGrid called "dgEvents"; one of the columns in the DataGrid is a template column and it is a TextBox called "txtEndDate". So, on Page Load, this column has a textbox in every row of the datagrid and there is no data in the textbox. The number of rows in the datagrid changes according to the search criteria the user used. What I want to do is, if the user puts a value (Date) in the textbox in any of the rows and when they click the Update Button, I want a pop-up message asking the user "Are you sure you want to do this?". If they click "Yes", I want to continue with the update else, I want to cancel the update. Well the problem is, I am not any good in JavaScript and I really need some help to get a javascript that will check to see if there is a value in any of the textboxes on the Update Button click event and if there is a value then have a pop up message asking "Are you sure you want to do this?" Please help JP 1. Define a client-side variable:
var changed=false; 2. For the textbox setup a client-side onchange event. In the event handler set changed=true; 3. For the update button setup client-side onclick event handler. In the event handler write: if (changed) return confirm("Are you sure you want to do this?"); else return true; Eliyahu Show quoteHide quote "JP" <J*@discussions.microsoft.com> wrote in message news:B7540788-69DE-40A0-9CA4-99FB993AFBDD@microsoft.com... > Hi; > I have a DataGrid called "dgEvents"; one of the columns in the DataGrid is > a template column and it is a TextBox called "txtEndDate". So, on Page Load, > this column has a textbox in every row of the datagrid and there is no data > in the textbox. The number of rows in the datagrid changes according to the > search criteria the user used. > > What I want to do is, if the user puts a value (Date) in the textbox in any > of the rows and when they click the Update Button, I want a pop-up message > asking the user "Are you sure you want to do this?". If they click "Yes", I > want to continue with the update else, I want to cancel the update. > > Well the problem is, I am not any good in JavaScript and I really need some > help to get a javascript that will check to see if there is a value in any of > the textboxes on the Update Button click event and if there is a value then > have a pop up message asking "Are you sure you want to do this?" > > Please help > JP You can wire the java script from your code in the ItemDataBound event of
the datagrid control. Sample code: TextBox tb=(TextBox)e.Item.FindControl("txtEndDate"); if(tb!=null) { tb.Attributes.Add("onclick","return confirm('Are you sure you want to do this?');"); } Show quoteHide quote "JP" <J*@discussions.microsoft.com> wrote in message news:B7540788-69DE-40A0-9CA4-99FB993AFBDD@microsoft.com... > Hi; > I have a DataGrid called "dgEvents"; one of the columns in the DataGrid is > a template column and it is a TextBox called "txtEndDate". So, on Page Load, > this column has a textbox in every row of the datagrid and there is no data > in the textbox. The number of rows in the datagrid changes according to the > search criteria the user used. > > What I want to do is, if the user puts a value (Date) in the textbox in any > of the rows and when they click the Update Button, I want a pop-up message > asking the user "Are you sure you want to do this?". If they click "Yes", I > want to continue with the update else, I want to cancel the update. > > Well the problem is, I am not any good in JavaScript and I really need some > help to get a javascript that will check to see if there is a value in any of > the textboxes on the Update Button click event and if there is a value then > have a pop up message asking "Are you sure you want to do this?" > > Please help > JP Well; the problem is that in design view, the name of the (edit templatge
item) textbox is "txtEndDate" but when you view the html source code in runtime the id of the textbox shows as "dgEvents__ctl1_txtEndDate" as the first control in the datagrid and the second row show as "dgWorkerSupervisor__ctl2_txtRoleEndDate" and so on. So the "ctl#" changes depends on how many rows you have in the datagrid. So, I am thinking I might have to have some kind of loop that will look for each textbox in the datagrid. But, I have no idea how to accomplish this though. JP Show quoteHide quote "Prodip Saha" wrote: > You can wire the java script from your code in the ItemDataBound event of > the datagrid control. > > Sample code: > TextBox tb=(TextBox)e.Item.FindControl("txtEndDate"); > > if(tb!=null) > > { > > tb.Attributes.Add("onclick","return confirm('Are you sure you want to do > this?');"); > > } > > > "JP" <J*@discussions.microsoft.com> wrote in message > news:B7540788-69DE-40A0-9CA4-99FB993AFBDD@microsoft.com... > > Hi; > > I have a DataGrid called "dgEvents"; one of the columns in the DataGrid > is > > a template column and it is a TextBox called "txtEndDate". So, on Page > Load, > > this column has a textbox in every row of the datagrid and there is no > data > > in the textbox. The number of rows in the datagrid changes according to > the > > search criteria the user used. > > > > What I want to do is, if the user puts a value (Date) in the textbox in > any > > of the rows and when they click the Update Button, I want a pop-up message > > asking the user "Are you sure you want to do this?". If they click "Yes", > I > > want to continue with the update else, I want to cancel the update. > > > > Well the problem is, I am not any good in JavaScript and I really need > some > > help to get a javascript that will check to see if there is a value in any > of > > the textboxes on the Update Button click event and if there is a value > then > > have a pop up message asking "Are you sure you want to do this?" > > > > Please help > > JP > > >
I've lost my drop down list box!
Columns are displayed twice binding ArrayLists to DataGrids-- how to name the columns? Newbie: Datagrid Comes Up Blank?!? DataRowView - deleting rows: A little quiz -or- Why doesn't this work... trying to display header only Wrong window gets the content ItemStyle question Datagrid Moving up and down Datagrid control in asp.net mobile web application |
|||||||||||||||||||||||