473,395 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

[C#&ASP.NET] javascript

In my web aplication I recover a list of members from a DataGrid. A colum of
the DataGrid is a TemplateColumn that call a javascript function that ask to
the client a confirm (a simple pop up) and then call the DeleteUser method
for the member cancellation. The javascript function seems to be correctly
load (infact the pop up appear) but the problem is that if i click on the
confirm button on the pop-up window, there isn't any cancellation(seems that
DeleteUser method don't is call). If I call the delete user metod directly,
without use of javascript function, there is a cancellation (the problem
isn't in the method code)

.......
<!--javascript between head tag-->
<script language="javascript">
function DeleteUser(id)
{
if (confirm('Sei sicuro di voler cancellare questo utente?'))
{
document.forms['Subscription'].elements['paramID'].value = id;
__doPostBack('DeleteUser', '');
}
}
</script>
......

<!-- In the Subscrition form there is SubscrGrid DataGrid with the following
TemplateColumn-->
<input id="paramID" type="hidden" name="paramID" runat="server">
<asp:datagrid id="SubscrGrid" runat="server" ...>
<Columns>
<asp:TemplateColumn><ItemTemplate>
<a href='<%# string.Format("javascript:DeleteUser({0});",
DataBinder.Eval(Container.DataItem, "UserID")) %>'><img
border="0" Alt="Delete this category" src="./Images/Delete.gif" /></a>
</ItemTemplate> </asp:TemplateColumn>
.....
</Columns></datagrid>

......
/*Then the DeleteUser method in the codebehin*/
protected void DeleteUser_Click(object sender, EventArgs e)
{
SubscrGrid.EditItemIndex = -1;
int userID = int.Parse(paramID.Value.ToString());
User studente = new User(userID);

[CUT]

BindGrid();
}

Thanks a lot
Nov 15 '05 #1
1 1727
From your javascript code you should be returning false to kill the event
"Darkoł" <no****@nospam.ns> wrote in message
news:DO*********************@tornado.fastwebnet.it ...
In my web aplication I recover a list of members from a DataGrid. A colum of the DataGrid is a TemplateColumn that call a javascript function that ask to the client a confirm (a simple pop up) and then call the DeleteUser method
for the member cancellation. The javascript function seems to be correctly
load (infact the pop up appear) but the problem is that if i click on the
confirm button on the pop-up window, there isn't any cancellation(seems that DeleteUser method don't is call). If I call the delete user metod directly, without use of javascript function, there is a cancellation (the problem
isn't in the method code)

......
<!--javascript between head tag-->
<script language="javascript">
function DeleteUser(id)
{
if (confirm('Sei sicuro di voler cancellare questo utente?'))
{
document.forms['Subscription'].elements['paramID'].value = id;
__doPostBack('DeleteUser', '');
}
}
</script>
.....

<!-- In the Subscrition form there is SubscrGrid DataGrid with the following TemplateColumn-->
<input id="paramID" type="hidden" name="paramID" runat="server">
<asp:datagrid id="SubscrGrid" runat="server" ...>
<Columns>
<asp:TemplateColumn><ItemTemplate>
<a href='<%# string.Format("javascript:DeleteUser({0});",
DataBinder.Eval(Container.DataItem, "UserID")) %>'><img
border="0" Alt="Delete this category" src="./Images/Delete.gif" /></a>
</ItemTemplate> </asp:TemplateColumn>
....
</Columns></datagrid>

.....
/*Then the DeleteUser method in the codebehin*/
protected void DeleteUser_Click(object sender, EventArgs e)
{
SubscrGrid.EditItemIndex = -1;
int userID = int.Parse(paramID.Value.ToString());
User studente = new User(userID);

[CUT]

BindGrid();
}

Thanks a lot

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: johkar | last post by:
When the output method is set to xml, even though I have CDATA around my JavaScript, the operaters of && and < are converted to XML character entities which causes errors in my JavaScript. I know...
1
by: Karl | last post by:
I'm trying to learn an acceptable way to marshal complex data between an ASP.NET web service and an ASP.NET web client. Initially, it will be enough for the client to display the data from the...
4
by: Asaf | last post by:
Hi, Is there any good book on C# ASP.NET with JavaScript? Thanks in advanced,
3
by: Karl | last post by:
Can Javascript code catch an exception thrown in an ASP.NET webservice? (Using XMLHTTPRequest object to send the SOAP message to the webservice.) If so, what't the Javascript syntax please? TIA
1
by: ceolino | last post by:
Hi all. I have a simple default.aspx file where I declare a JavaScript function: <script type="text/javascript" language="JavaScript"> .... function rotate() { .... } </script>
18
by: Andrew Wan | last post by:
I have been developing web applications with ASP & Javascript for a long time. I have been using Visual Studio 2003.NET. While VS2003 is okay for intellisense of ASP & Javascript, it's still not...
1
by: dungdang | last post by:
I have a file that contains a single colum per row, about 20,000 rows like : 2345607 2342374 2434522 1432334 1326514 7768518 7612364
1
by: rmat | last post by:
Hi, I'm an engineering student who's just started working with ASP.NET as part of a training program. The language I am to work with is Javascript, and though I do know how to work with HTML, I...
1
by: coolchippy | last post by:
I have two questions........ 1) How can i call a JavaScript function in asp.net code? I don't wan to call this function on any button click event instead i want to call this JavaScript function...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.