Como impedir a postagem no botão asp ao exibir um pop-up usando o JQuery
Eu tenho o seguinteItemTemplate
no meu GridView:
<ItemTemplate>
<asp:Button UseSubmitBehavior="false" runat="server" ID="btnShow" CssClass="btnSearch" Text="View All" CommandName="ViewAll" OnClientClick="myfunction(); return false;" OnCommand="btnShow_Command" CommandArgument='<%#((GridViewRow)Container).RowIndex%>' />
</ItemTemplate>
Para oItemTemplate
Eu tenho um botão que abre uma janela pop-up quando clicado usando o seguinte JQuery:
$(document).ready(function () {
$(".btnSearch").click(function (e) {
e.preventDefault();
//centering with css
centerPopup();
//load popup
loadPopup();
});
});
function myfunction() {
}
meuCommand
Código por trás:
protected void btnShow_Command(object sender, CommandEventArgs e)
{
int index = 0;
if (e.CommandName == "ViewAll")
{
index = Convert.ToInt32(e.CommandArgument);
DataTable cacheTable = HttpContext.Current.Cache["ResultsTable"] as DataTable;
string column = cacheTable.Rows[index].Field<string>("Guideline");
string test = BookingResults.Rows[index].Cells[7].Text;
string html = HttpUtility.HtmlDecode(column);
ResultsDiv.InnerHtml = html;
//tbGL.Text = html;
//upData.Update();
//MessageBox.Show(index.ToString());
}
}
Eu adicionei oOnClientClick="myfunction(); return false;"
porque estava fazendo um postback cada vez que clicava. Se eu tiver várias linhas, ele funcionará apenas na primeira vez em que clicar, mas a qualquer momento depois, o pop-up não será exibido quando outro botão ou o mesmo botão for clicado.
Como resolvê-lo para que, independentemente de qual botão seja clicado, o pop-up seja exibido sem fazer uma postagem?