Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onClientClick does not work correctly after deploying

Status
Not open for further replies.

bereza

Technical User
Jun 14, 2006
105
EU
Hi everybody,

I have created a little application which contains some datalists, repeaters. each item of the datalists or repeaters has a button which is used to delete the item. I have used onClientClick to get a confirm message when you want to delete an item. My code is working correctly in developing environement (VS 2008 .net 2.0). but I deploy it to production (same machine but another local disk - d:) it does not work correctly. It generates the confirm message but it deletes the item even when I click on Cancel. Thank you for any help.
here is my code:

asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<script language="javascript" type="text/javascript">

function ShowConfirmDelete() {
var theMessage = document.getElementById('<%=ConfirmMessage.ClientID%>').value;

return confirm(theMessage);
}

</script>

<asp:Repeater ID="DataList1" runat="server" DataSourceID="SqlDataSource1" >

<ItemTemplate>

asp:Label ID="itemdateLabel" runat="server" Text='<%# Eval("CreatedDate","{0:d}") %>' />

<asp:Button ID="RemoveBtn" runat="server" Text="delete" OnClientClick="return ShowConfirmDelete();" />

</ItemTemplate>

</asp:Repeater>

</asp:Content>
 
I have to say that when i browse to the site within the production machine it works but when i browse to production from another machine it generates event (page is reloaded).
first it generates the confirm message and it does not matter if you click on the ok or cancel it reloads the page and goes to the event btnDelete_Click and deltes the item.
 
What do you mean it runs correctly on your PC but not when you deploy it?

Post the code behind that runs the button click
 
here is the code behind.
I mean i have deployed it, when i run within my local network it works good but when i run outside of the network i generates the javascipt confirm message but it deletes the the when i click cancel.

protected void RemoveBtn_Click(object sender, EventArgs e)
{
AmedDataSetTableAdapters.LinksTableAdapter linkData = new AmedDataSetTableAdapters.LinksTableAdapter();
linkData.Delete(ObjectId);
Response.Redirect("~/Link/ListLink.aspx");
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top