views:

180

answers:

3

Hello,

I have been struggling with a problem that kept me busy for a few days now. I am programming c# .net web applications for an IE only environment and my current project contains a modal window. I hope you guys can help me out here!

I have a couple of response.redirects in my modal page that work fine, with the addition of in the aspx file. But I also have a listview which is filled at runtime, where I add a onclick event to a tablecell using the attributes.add method which fires java script to do the redirect. The problem is this: The methods I used, location.href='x'; and window.open('x','_self'); sadly opens the link in a new window instead of in the same.

Would somebody know a way around this or how to solve this? I would be very grateful for any help.

protected void lvConditions_ItemDataBound(object sender, ListViewItemEventArgs e)
{
       ...

       label.Attributes.Add("OnClick", "window.open('Condition.aspx?action=selectedcondition', '_self');");

       ...
}

Thanks

+1  A: 

use window.location instead of window.open()

 label.Attributes.Add("onclick", "window.location = 'Condition.aspx?action=selectedcondition';");
Daniel Dyson
A: 

Try using window.location instead of window.open?

Dave Swersky
A: 

I knew there was a third way to do the redirect in js, but I forgot this one... Unfortunately this did not help either, the new page was still opened in a new window.

I changed the application now to work round the problem. Instead of selecting by clicking on the cell, I added an ImageButton for each line to do the select. Their links (PostBackUrl) I set in runtime and it works like a charm.

I will keep the old code as well though to see if someone can actually come up with the real solution for this.

Thanks Daniel and Dave for your reply. Anyone else who wants the have a throw at this?

J.C.