tags:

views:

14

answers:

1

Hi AlL

I am trying to open an preview.aspx page in a seperate window from INSIDE an ajax modal popup. I have tried doing it with client side scripting using the onClientCLick preview.target _blank etc but this doesn't work at all. I have now managed to at least get this working within my lbPreview_Click routine but this requires a 2nd click because i am using the Attributes.Add to open window (the only way it would work so far!):

protected void lbPreview_Click(object sender, EventArgs e)
{
    string recordNo = lblRecordNo.Text;
    string details = txtQuery.Text;
    string reason = ddReason.SelectedItem.Text;
    string fullName = lblFullName.Text;
    string path = "emailPreview.aspx?recordNo=" + recordNo + "&details=" + details + "&reason=" + ddReason.SelectedItem.Text + "&fullName=" + fullName + "";
    lbPreview.Attributes.Add("onClick", "window.open('" + path + "');");
}

PLease note: I don't have the values to build my url path until the button has been clicked, so calling the details on page load or similar won't work either.

Any suggestions/help would be very much appreciated.

Kind Regards, ukjezza.

A: 

You should use java-script to lookup into control values to build the URL and then open the window. For example, consider following js function on aspx page

function openPreview() {

   var recordNo = document.getElementById('<%= lblRecordNo.ClientID %>').innerHTML;
   var details = document.getElementById('<%= txtQuery.ClientID %>').value;
   var reason = document.getElementById('<%= ddReason.ClientID %>').value;
   var fullName= document.getElementById('<%= lblFullName.ClientID %>').innerHTML;

   var url = "emailPreview.aspx?recordNo=" + recordNo + "&details=" + details + "&reason=" + reason + "&fullName=" + fullName;

   window.open(url);
}

Should be invoked on click of your preview button/link.

VinayC
Worked like a charm, many thanks for your help!! :-)
ukjezza