This is a migrated thread and some comments may be shown as answers.

How to pass URL to Edit Dialog Window and display URL content inside that Window

7 Answers 388 Views
Window
This is a migrated thread and some comments may be shown as answers.
gc_0620
Top achievements
Rank 1
gc_0620 asked on 25 Jan 2016, 09:41 PM

Folks, environment:  UI for ASP.Net Ajax Q1 2016 With VS 2013. and using below Telerik link as a prototype in my project.

I have a sql table in SQL Server that has 2 columns, 1) Link 2) URL (i.e. https://www.google.com/ or https://www.yahoo.com/) In my edit form, 
hyperlink button is pulling data (i.e. URL in Item Databound event.  Works fine.

  <table>
          <tr>
            <td style="font-size: 11px">Community District: </td>
            <td>
                <asp:TextBox ID="CDTextBox" Font-Size="11px" Text='<%# Bind( "CD") %>'
                    runat="server" TabIndex="8">
 
                </asp:TextBox>
                     
                <asp:HyperLink ID="HyperLinkCD" Style="text-decoration: underline; border-color: InfoBackground; margin: inherit; font-size: 12px; color: #228B22; font-family: Calibri; font-weight: 700"
                 Text="Link" Target="_blank"
                 runat="server" TabIndex="9"></asp:HyperLink>
            </td>
        </tr>
 
</table>
   
  protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    
   {  
 
        
    if (e.Item is GridEditableItem && e.Item.IsInEditMode && e.Item.OwnerTableView.Name == "Master")
    {
 
        GridEditableItem editem = (GridEditableItem)e.Item;
        TextBox txtcd = (TextBox)editem.FindControl("CDTextBox");
        string Stcd = txtcd.Text.ToString().TrimEnd();
        SqlCommand cmdcontrol = new SqlCommand("SELECT Link from Cd_Link" +
            "WHERE [CD] = '" + Stcd + "'", SqlConnection);
 
 
         SqlConnection.Open();
         
         SqlDataReader objDR = cmdcontrol.ExecuteReader();
         if (objDR.Read())
           {
        
               string stnycUrlLink = objDR["Link"].ToString().TrimEnd(); Pulling URL from SQL Column ex: https://www.google.com/ or https://www.yahoo.com/
               stnycUrlLink = "" + stnycUrlLink + "";
             
               HyperLink hyperLinkCD = (HyperLink)editem.FindControl("HyperLinkCD");
               hyperLinkCD.NavigateUrl = stnycUrlLink;
               hyperLinkCD.Attributes["href"] = "#";
               hyperLinkCD.Attributes["onclick"] = String.Format("return Show_CDMap('{0}');", stnycUrlLink);
               Session["MapSource"] = "Program";
               Session["Sturl"] = stnycUrlLink;
               
           }
                  
       }
         
  }
    
   function Show_CDMap(seltxt)
   {
               var seltxtbx = seltxt.value;
               alert(seltxt);       ex: https://www.google.com/ or https://www.yahoo.com/
               var oWind = window.radopen("ShowCDMaps.aspx", "UserListDialog");
               oWind.setSize(document.body.scrollWidth - 170, document.body.scrollHeight + 180);
               oWind.set_modal(true);
               oWind.Center();
               oWind.Maximize();
 
              return false;
       }
 
    

I would like to pass that URL to edit form and open that URL. Another word if hyperlink button is grabing https://www.yahoo.com/ from  SQL Table, then open https://www.yahoo.com/

inside edit dialog form.

http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=window

My codes are below. Any help will be appreciated.
gc_0620

7 Answers, 1 is accepted

Sort by
0
gc_0620
Top achievements
Rank 1
answered on 25 Jan 2016, 09:45 PM

using below Telerik Link as Prototype:

 

http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=grid

 

0
Marin Bratanov
Telerik team
answered on 26 Jan 2016, 08:19 AM

Hi gc_0620,

Both Google and Yahoo use the X-Frame-Origin HTTP header to prevent their site from being placed in an <iframe>, which is what RadWindow uses to load its content page. Thus, I suggest you simply test with other sites.

Regards,

Marin Bratanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
gc_0620
Top achievements
Rank 1
answered on 26 Jan 2016, 12:02 PM

Thanks Marin. I am not using Google or Yahoo sites nor storing their home page URL in my SQL Table Column Data. This was merely an example.

Lets see I have 2 url's in my sql table column (http://www.nytimes.com/  or http://www.nydailynews.com/). My hyperlink grabs that in Item Databound event into string stnycUrlLink.

All I want by clicking that hyperlink, open the corresponding URL (i.e. home page of NY Times or NY Daily News Site) within a Radwindow like below Telerik Link.

http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=grid

 

Thanks

0
Marin Bratanov
Telerik team
answered on 27 Jan 2016, 08:31 AM

Hi gc_0620,

What is the exact problem with the RadWindow control that you are experiencing? I see the following code which is expected to open a concrete page from your project and not some other URL:

window.radopen("ShowCDMaps.aspx", "UserListDialog");

If you want to open another page in the RadWindow you should replace this with the desired URL, e.g.:

window.radopen("http://www.nytimes.com/", "UserListDialog");

If you are having difficulties passing that as an argument to a JS function I can suggest considering the following options:


Regards,

Marin Bratanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
gc_0620
Top achievements
Rank 1
answered on 27 Jan 2016, 10:28 PM

Hi Marin,

Let me clear my intended steps:

1) Open a concrete page (ShowCDMaps.aspx) from project after clicking the Hyperlink button

window.radopen("ShowCDMaps.aspx", "UserListDialog");

2) When that page opens, show the below url inside a Radwindow within that concrete page.

Is it possible to accomplish this? Please suggest.

Regards

gc_0620

0
gc_0620
Top achievements
Rank 1
answered on 28 Jan 2016, 01:11 AM

Hi Marin, I would like to clarify my latest post for #2

http://www.nytimes.com/ is not a static value.

In my project, I am storing all my URL's in a SQL Table Column. Ex 3 rows:

http://www.nytimes.com/

http://www.telerik.com/

http://www.nfl.com/

So depending on the retrieved URL value grabbed inside item databound event, open the home page of retrieved URL inside a Radwindow within the concrete page (ShowMaps.aspx).

I already sent item databound event code to retrieve URL values from SQL Table in my previous post.

Thanks

 

 

0
Marin Bratanov
Telerik team
answered on 28 Jan 2016, 07:59 AM

Hello gc_0620,

RadWindow only has a single iframe, so it cannot open both the page from the database (e.g., NY Times) and the ShowCDMaps.aspx page designated in the radopen() method.

If you want to have them both, you should either open two RadWindow instances, or add an <iframe> element whose src attribute you can set according to your preferences.

Regards,

Marin Bratanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Window
Asked by
gc_0620
Top achievements
Rank 1
Answers by
gc_0620
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or