[C#&ASP.NET] javascript

  • Thread starter Thread starter Darko³
  • Start date Start date
D

Darko³

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
 
Back
Top