You are currently browsing the Web category
Displaying 1 - 3 of 4 entries.

Loading pages in IFRAME dynamically from codebehind – ASP.NET

  • Posted on 7월 1, 2011 at 8:04 오전

Most of us who develop Web Applications would have used an IFRAME during some stage of our lives. IFRAME’s are an easy way by which you can embed another page within your original page such that you can show some important information like Stock position/Weather from another site without worrying about the changes happening to that site and updating the same. The Frame can also be used to show another page from your own application.

ASP.NET also provides the option to have an IFRAME in our ASPX Pages. It can be with/without the “runat=server” attribute and does serve the purpose of embedding the page. The source for the frame can be set as follows:-

 

<IFRAME id=”frame1″ src=”SourcePage.extension / URL of the external Site” scrolling=”auto”>
</IFRAME>


However, in practical scenarios, we may want to load the page dynamically. In other words, we may want to specify the “src” attribute (the page which we want to show), dynamically. There is no straight forward way to do that and even if you add a “runat=server” attribute to it (though required in the work around provided below), you cannot access the “src” property directly.

The workaround to do that is as follows:-

1. Specify the “runat=server” attribute as follows in the ASPX Page:-

<IFRAME id=”frame1″ scrolling=”auto” runat=”server”>
</IFRAME>

2. In the codebehind, you may need to declare a HtmlGenericControl in the control declarations section as follows:-
 

C#
protected System.Web.UI.HtmlControls.HtmlGenericControl frame1; (not required if working with ASP.NET  2.0, 3.5 i.e. Visual Studio 2005, 2008)
 
VB.NET
Protected WithEvents frame1 As System.Web.UI.HtmlControls.HtmlGenericControl (not required if working with ASP.NET  2.0, 3.5 i.e. Visual Studio 2005, 2008)
 
3. Then, you need to do a findcontrol to identify the control on the page and typecast it as follows:-
 

C#
HtmlControl frame1 = (HtmlControl)this.FindControl(“frame1″); (not required if working with ASP.NET  2.0, 3.5 i.e. Visual Studio 2005, 2008)
  
VB.NET
Dim frame1 As HtmlControl = CType(Me.FindControl(“frame1″), HtmlControl) (not required if working with ASP.NET  2.0, 3.5 i.e. Visual Studio 2005, 2008)

Note: You can have different name for the Generic Control you define in the code behind, but for ease I keep both the same. The “frame1″ referred in Find Control is the ID as declared in the ASPX Page.

4. Thereafter, you will be able to access the src property as follows:-


 
 

C#
frame1.Attributes["src"] = “http://www.live.com” ;

 

VB.NET
frame1.Attributes(“src”) = “http://www.live.com” ;
  
NOTE: Thanks PhOeNiX for providing the VB.NET equivalent.  I have added the same now.

As you can see though I have hard-coded the URL you can assign it dynamically based on a condition or any other business logic.

This serves the purpose of dynamically loading the page in the IFRAME.

Cheers !!!
 

IIS7.5 + PHP에서 MS-SQL사용

  • Posted on 2월 16, 2011 at 8:21 오후

IIS7.5 ( Windows Server 2008 R2 )에서 PHP5를 설치하고 MS-SQL가 활성화가 안돼서 한참을 씨름했다.

여기저기 뒤져서 Microsoft Drivers for PHP for SQL Server를 찾아서 깔고 나서야 사용 할 수 있었다.  

한심한것은 8개월여전에 한번 씨름했던 기억이 나는것!!

* PHP 5.2.4, or later

  • Filed under:

WordPress IIS7 500.50 Error

  • Posted on 2월 15, 2011 at 10:45 오후

워드프레스는 링크를 여러가지로 표현하도록 지원하고 있다.

 http://2yun.pe.kr/?p=123  )와

정적인 폴더에 접근하는 것처럼하는 사용자 정의 링크 (http://2yun.pe.kr/archives/123) 가 있는데 개인적으로 사용자 정의 링크가 깔끔해서 선호한다.

 

 

 문제는 IIS에 설치할 경우 iis의 rewrite 모듈을 활용하는데 잘 되다가도 가끔씩  500에러가 난다.

원인을 찾던중 아래 링크에서 권한 문제임을 알게 되었고 조치 했다.

http://www.howyoudo.info/index.php/how-to-fix-windows-server-upload-file-inherit-permissions-error/ 

대략의 내용은 php의 업로드 임시폴더위치와 권한을 관리할 것으로 권하고 있다.

하지만 권하는 방법으로도 잘 안되서 해당 폴더의 권한을 조정하였다.

  • Filed under: