Hello, I` making board using GridView.
And now, I want to make like this :
1. If Checkbox is checked in GridView and click modify Button, open popup windows
2. Else alert message 'Please check your item'
I clicked the button below code, When I choose nothing, alert message showed,
and I checked checkbox and press button, also alert message showed.not opened popup
window.
But instead of javascript , if I use code
Response.Redirect("UserBoard_Edit.aspx?BoardItemID=" + boardItemID);
it works well.
I don`t know why It`s not fired...
Is it possible making one javascript function?
Please help me.....
What I have tried:
--- This is .aspx page ---
<asp:LinkButton ID="lnbEdit" runat="server" Text="Edit" OnClick="lnbEdit_Click">
<asp:GridView ID="grvList" DataKeyNames="BoardItemID" runat="server" AutoGenerateColumns="False" >
<columns>
<asp:BoundField HeaderText ="boardItemID" DataField="BoardItemID" HeaderStyle-CssClass="hidden">
<itemstyle cssclass="hidden" />
<asp:BoundField HeaderText="conNo" Visible="false" DataField="indexNo" />
<asp:TemplateField>
<itemtemplate>
<asp:CheckBox ID="chk" runat="server"/>
</itemtemplate>
...
...
</columns>
--- This is code behind page ---
protected void lnbEdit_Click(object sender, EventArgs e)
{
foreach (GridViewRow gRow in grvList.Rows)
{
CheckBox chk = (CheckBox)gRow.FindControl("chk");
if (chk.Checked)
{
int boardItemID = Convert.ToInt32(gRow.Cells[0].Text);
string popURL = "UserBoard_Edit.aspx?BoardItemID=" + boardItemID;
string openPopUp = @"
<script type='text/javascript'>
popup = window.open('" + popURL + "', 'open_window', 'width = 880, height = 500, left = 0, top = 0'); popup.focus();</script>";
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", openPopUp);
}
else
{
string message = @"
<script type='text/javascript'>
alert('Please check your Item');
</script>";
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", message);
}
}
}