I have a page with a ckeditor in it, and a "save button". On load, i put some text on the editor for the user to edit and then save. I am experiencing some troubles with the save button.
I have the following code on my code behind.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Some Code
Protected Sub btgravar_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btgravar.Click
Some Code
In normal cases, and if i put a breakpoint on the first line of the two events, the page load is fired and then the click event. In some cases (and i couldn't figure out when) the click event is not fired. The page load fires, and then the page refreshes without any signal of the save button.
I thought that if some exception was thrown on the page load event, this could prevent the second event from firing. However, i followed all the code in debug mode and there's no exception thrown and when it come开发者_JAVA技巧s to and end, the page simply refreshes.
Any idea on why this is happening?
EDIT: The editor and the buttons (save and return) are inside a table, here it is some of the aspx code (the table closing element is not there because there's more cede below this one)
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 18px;" id="TABLE1" language="javascript" onclick="return TABLE1_onclick()">
<tr>
<td style="width: 24px; height: 25px; text-align: right">
<asp:ImageButton ID="ImageButton1" runat="server" Height="20px" ImageUrl="~/Imagens/retorna.gif"
Width="20px" /></td>
<td style="width: 7px; height: 25px;">
<span style="font-size: 8pt; color: black"> Cancelar</span></td>
<td style="width: 28px; height: 25px; text-align: right">
<asp:ImageButton ID="btgravar" runat="server" Height="20px" ImageUrl="~/Imagens/gravar.gif"
Width="20px" ToolTip="Gravar Relatório" />
</td>
<td style="width: 46px; height: 25px;">
<span style="font-size: 8pt; color: #006666"> <asp:Label ID="lblgravar" runat="server"
Font-Bold="False" Font-Size="8pt" ForeColor="Black">Gravar</asp:Label></span></td>
-
<form id="form1" runat="server" enctype="multipart/form-data" >
-
function TABLE1_onclick() {
}
The TABLE1_onclick() has actually no meaning and probably can be taken out from the table definition(?)
EDIT2: I tried removing the onclick from the table: no change. I have also already tried to take the image button off the table and directly into the page and the behaviour persists.
(If you want me to provide more details/code of my page, just ask)
I think I see something:
btgravar is missing the OnClick event handler. You should add OnClick="btgravar_Click" to the image button.
If you are adding it somewhere in your page load with
btgravar.Click += new ImageClickEventHandler(btgravar_Click);
and make sure you are doing it on every page load even on postback.
Edit: the onclick would only cancel the action if it was return false, and you did return in the onClick as well. This is what I originally thought, but I did some testing with what you posted and it seems like it is ok.
精彩评论