how to open a new aspx page like a pop-up window on clicking on a check box inside a gridview,my checkbox is inside the gridview.on clicking of the checkbox i need to show show my aspx page like a new window/pop-up window.so that i can fill the form(my aspx
page) and submit it .
Thanks a lot me_ritz sir for helping me out,my half of the problem is resolved......i got my addmaster.aspx page opening like a new window.further i need to ask u some questions
1) After checking the checkbox in the gridview i need to get values of selected checkbox row in my new opened window.
how can i get all the values from the checkbox selected row in my newly opened addmaster,aspx page..
2) before the new window pop-up, a small pop-up window is also displayed "the local host IP number" says "on",i want my first column name value i.e id associated with the checkbox checke,i mean to say i need my id number with respective to the check box
clicked.
i have changed "Id " to "id" ,but i am not getting id value,instead i amgetting "on"
To me-ritz Sir as per ur suggestion updated the code ,now i am getting two pop-up window before my newly opened addmaster.aspx window.
1st pop-up window shows me the id(thats perfect),
but the second pop-up windows gives me a dialog box saying "The local-host at ip number says" then a checkbox and Prevent this page fromcreating additional dialog,after checking the checkbox in the dialog box or pressing ok in the second dialog box,,when
the third time i check any boxes in my gridview,i am not able to get my first checkbox with respective id.as soon as i check any checkbox in the gridview i am dirctly geting my new addmaster.aspx window...kindly offer any suggestion
I posted the code to make you understand how you can get your problem solved. You need to use logic to get that done.
Rounak Rana
but the second pop-up windows gives me a dialog box saying "The local-host at ip number says" then a checkbox and Prevent this page fromcreating additional dialog,after checking the checkbox in the dialog box or pressing ok in the second dialog box
Modify the code as below to remove the message:
function foo(Id, Index, obj) {
if (obj.checked) {
alert(Id); //"Id" field
alert(Index); //Row Index (1-based)
window.open('http://www.google.com', '', 'left=25%, top=25%, width=1002px, height=650px, scrollbars=no, status=no, resizable=no');
}
}
Rounak Rana
when the third time i check any boxes in my gridview,i am not able to get my first checkbox with respective id.as soon as i check any checkbox in the gridview i am dirctly geting my new addmaster.aspx window
the code is written as such to get the id & index of the currently checked checkbox.
sir i am new bie to the asp.net ,i am still on the learning stage ,.........i am still getting the dialog box saying "Prevent this page from crating additonal "
Rounak Rana
Member
48 Points
237 Posts
how to open a new aspx page on clicking on acheck box inside a gridview
Apr 09, 2012 06:45 AM|LINK
how to open a new aspx page like a pop-up window on clicking on a check box inside a gridview,my checkbox is inside the gridview.on clicking of the checkbox i need to show show my aspx page like a new window/pop-up window.so that i can fill the form(my aspx page) and submit it .
kimkosta06
Member
270 Points
50 Posts
Re: how to open a new aspx page on clicking on acheck box inside a gridview
Apr 09, 2012 06:50 AM|LINK
you should use javascript for above purpose, onclick or onchange event call javascript function.
javascript function call window.open method to open new popup with specify page name.
tarunSaini
Contributor
2948 Points
985 Posts
Re: how to open a new aspx page on clicking on acheck box inside a gridview
Apr 09, 2012 06:51 AM|LINK
take a template field
inside you take a checkbox
in codebehind:
checkbox ch=(checkbox)gridview1.SelectedRows.cells[0].findControl("id of check box");
if(ch.selectedIndex==0)
{
response.redirect("url");
}
me_ritz
Star
9337 Points
1447 Posts
Re: how to open a new aspx page on clicking on acheck box inside a gridview
Apr 09, 2012 07:05 AM|LINK
Copy-paste and test it.
HTML
<script type="text/javascript"> function foo(obj) { if (obj.checked) { alert(obj.value); //In case you need id window.open('http://www.google.com', '', 'left=25%, top=25%, width=1002px, height=650px, scrollbars=no, status=no, resizable=no'); } } </script> <asp:GridView ID="gv" runat="server" AutoGenerateColumns="false"> <Columns> <asp:TemplateField HeaderText="select"> <ItemTemplate> <input id="chkSelect" type="checkbox" onclick='foo(this);' value='<%#Eval("Id").ToString() %>' /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Name" HeaderText="Name" /> </Columns> </asp:GridView>C#
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { gv.DataSource = Bind2(); gv.DataBind(); } } protected DataTable Bind2() { DataTable table = new DataTable(); table.Columns.Add("Id"); table.Columns.Add("Name"); DataRow row = null; row = table.NewRow(); row["Id"] = "1"; row["Name"] = "A"; table.Rows.Add(row); row = table.NewRow(); row["Id"] = "2"; row["Name"] = "B"; table.Rows.Add(row); table.AcceptChanges(); return table; }Thanks
AmalO.Abdull...
Contributor
3116 Points
764 Posts
Re: how to open a new aspx page on clicking on acheck box inside a gridview
Apr 09, 2012 07:10 AM|LINK
ok in databound if that grid view do the following
1- find the check box control as following
dim chk as checkBox = ctype(e.row.findcontrol("id"),checkbox)
2 - add this function to it.
chk.attributes.add("onclick","javascript:openNew('"& chk.clientID & "');"
3- you javascript code should be like that
function OpenNew(chk)
{
var check = document.getElementbyId(chk).checked;
if(check == true)
{
window.open("yourur", "mywindow", "status=1,toolbar=1,scrollbars=yes");
}
}
4- in that particular page you are openning do the following
if your content inside a tabled give it a with of 600px
try it and let me know
Rounak Rana
Member
48 Points
237 Posts
Re: how to open a new aspx page on clicking on acheck box inside a gridview
Apr 09, 2012 08:43 AM|LINK
Thanks a lot me_ritz sir for helping me out,my half of the problem is resolved......i got my addmaster.aspx page opening like a new window.further i need to ask u some questions
1) After checking the checkbox in the gridview i need to get values of selected checkbox row in my new opened window.
how can i get all the values from the checkbox selected row in my newly opened addmaster,aspx page..
2) before the new window pop-up, a small pop-up window is also displayed "the local host IP number" says "on",i want my first column name value i.e id associated with the checkbox checke,i mean to say i need my id number with respective to the check box clicked.
i have changed "Id " to "id" ,but i am not getting id value,instead i amgetting "on"
<input id="chkSelect" type="checkbox" onclick='foo(this);' value='<%#Eval("id").ToString() %>' />me_ritz
Star
9337 Points
1447 Posts
Re: how to open a new aspx page on clicking on acheck box inside a gridview
Apr 09, 2012 09:24 AM|LINK
I Updated code. Please test
<script type="text/javascript"> $(document).ready(function () { }); function foo(Id, Index, obj) { alert(Id); //"Id" field, Use it wherever you need alert(Index); //Row Index (1-based), Use it wherever you need if (obj.checked) { window.open('http://www.google.com', '', 'left=25%, top=25%, width=1002px, height=650px, scrollbars=no, status=no, resizable=no'); } } </script> <asp:GridView ID="gv" runat="server" AutoGenerateColumns="false"> <Columns> <asp:TemplateField HeaderText="select"> <ItemTemplate> <input id="chkSelect" type="checkbox" onclick='<%# "foo(\"" + Eval("Id").ToString() + "\",\"" + (Container.DataItemIndex + 1) + "\",this);"%>' /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Name" HeaderText="Name" /> </Columns> </asp:GridView>Thanks
Rounak Rana
Member
48 Points
237 Posts
Re: how to open a new aspx page on clicking on acheck box inside a gridview
Apr 09, 2012 10:52 AM|LINK
To me-ritz Sir as per ur suggestion updated the code ,now i am getting two pop-up window before my newly opened addmaster.aspx window.
1st pop-up window shows me the id(thats perfect),
but the second pop-up windows gives me a dialog box saying "The local-host at ip number says" then a checkbox and Prevent this page fromcreating additional dialog,after checking the checkbox in the dialog box or pressing ok in the second dialog box,,when the third time i check any boxes in my gridview,i am not able to get my first checkbox with respective id.as soon as i check any checkbox in the gridview i am dirctly geting my new addmaster.aspx window...kindly offer any suggestion
me_ritz
Star
9337 Points
1447 Posts
Re: how to open a new aspx page on clicking on acheck box inside a gridview
Apr 09, 2012 11:10 AM|LINK
I posted the code to make you understand how you can get your problem solved. You need to use logic to get that done.
Modify the code as below to remove the message:
function foo(Id, Index, obj) { if (obj.checked) { alert(Id); //"Id" field alert(Index); //Row Index (1-based) window.open('http://www.google.com', '', 'left=25%, top=25%, width=1002px, height=650px, scrollbars=no, status=no, resizable=no'); } }the code is written as such to get the id & index of the currently checked checkbox.
Thanks
Rounak Rana
Member
48 Points
237 Posts
Re: how to open a new aspx page on clicking on acheck box inside a gridview
Apr 09, 2012 11:50 AM|LINK
sir i am new bie to the asp.net ,i am still on the learning stage ,.........i am still getting the dialog box saying "Prevent this page from crating additonal "
below is my aspx page
<%@ Page Language="C#" MasterPageFile="~/MASTERS/master.master" AutoEventWireup="true" CodeFile="showallnewrequest.aspx.cs" Inherits="MASTERS_showallnewrequest" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.style7
{
width: 150px;
}
.style8
{
width: 79px;
}
.style10
{
width: 134px;
}
.style11
{
width: 43px;
}
</style>
<script type="text/javascript">
function foo(Id, Index, obj) {
if (obj.checked) {
alert(Id); //"Id" field
alert(Index); //Row Index (1-based)
window.open('addmaster.aspx', '', 'left=25%, top=25%, width=800px, height=670px, scrollbars=no, status=no, resizable=no');
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<p>
<br />
<table style="width:100%;">
<tr>
<td class="style7">
</td>
<td class="style11">
</td>
<td class="style10">
View Request For:</td>
<td class="style8">
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</td>
<td>
</td>
</tr>
</table>
</p>
<p>
</p>
<p>
<asp:Panel ID="Panel1" runat="server" Height="349px" Width="674px"
ScrollBars="Horizontal" style="margin-left: 0px">
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None" AllowPaging="True"
onpageindexchanging="GridView1_PageIndexChanging">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:TemplateField HeaderText="Check">
<ItemTemplate>
<input id="chkSelect" type="checkbox" onclick='<%# "foo(\"" + Eval("Id").ToString() + "\",\"" + (Container.DataItemIndex + 1) + "\",this);"%>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<EmptyDataTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</EmptyDataTemplate>
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
</asp:Panel>
</p>
<p>
</p>
</asp:Content>