Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Dear Guys,

This is Shiva,I'm creating chat application now.I have one Major problem.I have placed Currently Online persons in datagrid,I have to open a seperate pop-up window for each person but now i can't able open a seperate window tats only my problem.Using linkbutton If i'm trying to open new window means each time the old pop-up window gets replaced by new window.I need open Seperate pop-up window for each linkbutton event What I have to Do? Please Help Me Friends

Please Help me It's Urgent...

Thanks in advance


Regards

Shiva
Posted

Give different names to the new windows and it will open different all the time.

Right now, you must be using same name in all the cases for the new window. This forces to open in the existing one only.

For ex: 'myWindowName' is the name that needs to be different all the time.
JavaScript
var reportWindow = window.open('CostByProject.aspx', 'myWindowName','height=650,width=900,resizable=1,status=yes,scrollbars=1,toolbar=no,menubar=no,location=no');



UPDATE:
piramanayagam.shiva wrote:
Page.ClientScript.RegisterStartupScript(this.GetType(),"op", "window.open ('" + Request.ApplicationPath + "/Operators/Chat.aspx', null,'width=450,height=450,left=350,top=120');", true);

You need to change this 'null' to a unique string.

Thus do something like:
C#
private int iCount = 0;
private string myNewWindow = String.Empty;

protected void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs e) 
{ 
   myNewWindow = "myNewWindow" + iCount.ToString();
   if (e.CommandName == "elink") 
   { 
     Page.ClientScript.RegisterStartupScript(this.GetType(),"op", "window.open ('" + Request.ApplicationPath + "/Operators/Chat.aspx','"+ myNewWindow+"','width=450,height=450,left=350,top=120');", true); 
   } 
   iCount++;
}

This could had been done other ways too. This is one of them.
 
Share this answer
 
v3
Comments
piramanayagam.shiva 20-Jul-10 7:42am    
Dear Sandeep Mewara,
Thank You for replying me once again..your correct sir but i'm having that linkbutton in datagrid sir how it is possible to give different names for each time please help me to do this..

Thanks & Regards

Shiva
Sandeep Mewara 20-Jul-10 8:03am    
Even though it is in Gridview, you must be binding this Javascript somewhere. Right? Wherever you associate this Javascript to create new window, make sure you have unique/different names all the time.
piramanayagam.shiva 20-Jul-10 8:32am    
Dear Sandeep Mewara,
I mention my code bellow please guide me how to change name....
protected void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs e)
{
if (e.CommandName == "elink")
{
Page.ClientScript.RegisterStartupScript(this.GetType(),"op", "window.open ('" + Request.ApplicationPath + "/Operators/Chat.aspx', null,'width=450,height=450,left=350,top=120');", true);
}


Thanks & regards
Shiva
Sandeep Mewara 20-Jul-10 8:43am    
Hope you got it this time and the answer is acceptable to you!
piramanayagam.shiva 20-Jul-10 8:56am    
Sorry sir,now javascript is showing error.
ERROR IS: myNewWindow0 is Undifined.

What can i do now?
Hi Shiva

try to use DataNavigateUrlFormatString property of HyperLinkField for the datagrid/ gridview column use below code

<br />
<br />
<asp:GridView ID="gvQueue" runat="server" DataSourceID="odsQueues" AutoGenerateColumns="False" HeaderStyle-BackColor="white" HeaderStyle-ForeColor="black" BorderColor="Black" BorderStyle="Solid" DataKeyNames="personid"><br />
 <Columns><br />
                <asp:HyperLinkField DataNavigateUrlFields="PersonID" DataNavigateUrlFormatString="/Operators/Chat.aspx?PersonID={0}"<br />
                    DataTextField="Person" HeaderText="Person ID" Text="AuditId" Target="_blank"  ><br />
<br />
                </asp:HyperLinkField><br />
 </Columns><br />
</asp:GridView><br />
<br />
 
Share this answer
 
v3
Comments
piramanayagam.shiva 21-Jul-10 3:49am    
Dear Rajesh Sajjanar,

Thank U very much for your,I got answer but i need open that chat.aspx in a pop-up window.so i have call a javascript inside it i try to find the way but i can't able to get it.Please help me is there any way to solve this problem..

Thanks & Regards
Shiva
piramanayagam.shiva 22-Jul-10 2:11am    
Hi Rajesh,

I have to call javascript inside hyperlinkfield is it possible.

Regards
shiva
Hi Shiva,

Call the Javascript function on datagrid linkbutton clicked
function()<br />
{<br />
window.open("URL");<br />
}
 
Share this answer
 
Comments
piramanayagam.shiva 20-Jul-10 7:31am    
Dear Rajesh,

I'm Already using window.open function for pop-up window.For example in datagrid i'm having 4 values ie(Linkbutton) means when i'm clicking each linkbutton i have to open 4 pop-up window..this is my Query what i have to do for this.
Thanks for ur immediate response Please help me to solve this.

Regards
Shiva
Sandeep Mewara 20-Jul-10 8:04am    
Reason for my vote of 1
Well, this would now resolve his issue. Having a Window.Open as you say would always open the same window which is the issue here.
Rajesh Sajjanar 22-Jul-10 1:59am    
Hi, Sandeep
Window.Open will not open in the same window, windows.location will open in the same window

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900