Hello everyone,
I have a Gridview , whose first column is template colums which contains checkboxes , outside my GridView I a have a delete button.
So in this application,when the user check any checkbox ,and when click on the delete button , it should ask for the confirmation 'Are you sure you want to delete these records'.
But you Know my problem is that:
I have added the following line to page_load event:
btnDelete.Attributes.Add["onclick"]="return confirm('Are you sure you want to delete these records')";
On running it works but it also asks for confirmation when I have not selected any of the checkboxes.
So please give me the solution ,whether I should add any javascript function for checking whether the checkbox has been checked or not.
But I don't know how to make that javacript function for checking whether the checkbox of the GridView are selected or not .Plese help me.
4 1281
One one would be to use a separate event and not use the page_load. HTH.
Thank you for replying.But it will be better if you will explain me more precisely.
what I asked was:
I have a Gridview , whose first column is template colums which contains checkboxes , outside my GridView I a have a delete button.
So in this application,when the user check any checkbox ,and when click on the delete button , it should ask for the confirmation 'Are you sure you want to delete these records'.
But you Know my problem is that:
I have added the following line to page_load event:
btnDelete.Attributes.Add["onclick"]="return confirm('Are you sure you want to delete these records')";
On running it works but it also asks for confirmation when I have not selected any of the checkboxes.
So please give me the solution ,whether I should add any javascript function for checking whether the checkbox has been checked or not.
But I don't know how to make that javacript function for checking whether the checkbox of the GridView are selected or not .Plese help me.
something like this
//This will be part of your aspx /ascx file
<INPUT id="btnDelete" type="button" value="Delete" name="btnDelete"
runat="server">
function ConfirmSave(msg)
{
var confirmationvalue = confirm(msg);
} //This will be part of your aspx.cs /ascx.cs file
private void btnDelete_ServerClick(object sender, EventArgs e)
{
int cnt;
cnt= Grid.Items.Count;
for (int i=0; i<cnt; i++)
{
CheckBox chkBox = Grid.Items[i].Cells[0].Controls[1] as CheckBox;
if (chkBox.Checked)
{
ExecuteScript(this.Page, "ConfirmSave('Your message text');");
}
}
}
public static void ExecuteScript(Page webpage_, string script_)
{
StringBuilder scriptBuilder = new StringBuilder( @"<script language=JavaScript>");
scriptBuilder.Append(script_);
scriptBuilder.Append(@"</script>");
JavaScriptUtil.RegisterScript(webpage_, "2", scriptBuilder.ToString());
webpage_.Response.Write(scriptBuilder.ToString());
}
Thank you for replying to my query.
But when I used what u have suggested but my application gives me error like:
JavaScriptUtil is not in the current context.
Please help me.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mike Turco |
last post by:
I'm working on an application that imports and exports tons of CSV data,
like 64,000 records per file, and six or seven files in a set.
First off, by the tine I import a few hundred thousand...
|
by: mpenev |
last post by:
Hi,
Is there a way to make the GridView ask for a confirmation (something
similar to javascript: window.confirm ) before deleting a row?
Thanks
|
by: ASMJ |
last post by:
Hi,
I have a gridview in my page, which displays all records from an
sqldatasource.
The delete row command is available to the user, through which he can
perform deletion.
I want to trap the...
|
by: Randy Smith |
last post by:
Hi ALL,
I wonder if anyone has been using n-tier to bind to a GridView control by
using the ObjectDataSource. This is our first OOP web application, and we
have no tables. Right now we are...
|
by: Frank Swarbrick |
last post by:
We have a batch process that inserts large numbers (100,000 - 1,000,000) of
records into a database each day. (DL/I database.) We're considering
converting it to a DB2 table. Currently we have...
|
by: Ronald S. Cook |
last post by:
I was told that if calling lots of records from the database (let's say
100,000), that the GridView's paging feature would automatically "handle"
everything.
But the 100,000 records are still...
|
by: johnmott |
last post by:
Hi all,
One of the limitations of the GridView control is that the built-in
delete processing doesn't prompt for confirmation -- something thats
very important for a user interface. True, you...
|
by: sweetpotatop |
last post by:
Hi,
I have a page written in C# asp.net, which allow users to select and
delete records.
Once user selects the record to be deleted, I will confirm with the
user, something like "Are you sure...
|
by: ITCraze |
last post by:
Thank you for replying.
It is giving the error:
: The name 'JavaScriptUtil' does not exist in the current context
Iam using ASP.NET 2005
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |