For training related to .net,OOPS,design patterns, MVC,WCF and .net fundamentals
contact at sukeshmarla@gmail.com or Click Here

Click here for my training feedbacks

Followers

Follow Us



Share your Interview questions here


For software development queries contact SukeshMarla@Gmail.com

Follow by Email

Learn everything about MSBI

14 February 2011

Reading IFrame Contents

Consider an aspx page with IFrame as
   1: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="PageWithIFrame.aspx.cs" Inherits="PageWithIFrame" %>
   2: <html>
   3: <body>
   4:     <form id="form1" runat="server">
   5:     <div> <asp:TextBox runat="server" ID="TxtName"></asp:TextBox>
   6:     </div>
   7:     </form>
   8: </body>
   9: </html>

Page which contain IFrame
1: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="PageThatUsesIFrame.aspx.cs" Inherits="PageThatUsesIFrame" %> <html>
   2:   <head>
   3:       <script src="Script/jquery.js" type="text/javascript"></script>
   4:   </head>
   5:   <body>
   6:       <form id="form1" runat="server">
   7:       <div>
   8:           <iframe id="upfMyFrame" scrolling="no" frameborder="0" style="border-style: none; margin: 0px; width: 100%; height: 40px;" src="PageWithIframe.aspx"></iframe>    
   9:           <asp:Button runat="server" ID="btnSet"  Text="Set Textbox Value" />
  10:       </div>
  11:       </form>
  12:   </body>
  13:   </html>

Now the Jquery code to read the content
1: <script language="javascript">
   2:      $(document).ready
   3:      (
   4:         function() 
   5:         {
   6:             $("#btnSet").click
   7:             (
   8:                  function() 
   9:                  {
  10:                      alert($('#upfMyFrame').contents().find("body #txtName").val());
  11:                      return false;
  12:                 }
  13:            );
  14:        }
  15:      );
  16:   </script>
  17:  

Get the execution time for .net code


using System;
using System.Diagnostics;
using System.Threading;
class ClsCalculateExectionTime
{
    public static void Main(string[] StrPriArgs)
    {
        Stopwatch ObjPriWatch= new Stopwatch();
        ObjPriWatch.Start();
       
       // Your Custom Code Start
      // Your Custom Code End
ObjPriWatch.Stop(); TimeSpan ObjPriSpan= ObjPriWatch.Elapsed;
    }
}