Tuesday, July 21, 2015

Dynamic Set the Height of Iframe by its Content Jquery JavaScript

Go through these simple Steps: 

step 1: Make Iframe with onload event
 
<IFRAME SRC="usagelogs/default.aspx" width="100%" height="200px" id="iframe1"  
 marginheight="0" frameborder="0" onLoad="autoResize('iframe1');"></iframe> 

Step 2: Write autoResize(id) Function
 
<script language="JavaScript">
function autoResize(id){
    var newheight;
    var newwidth;
    if(document.getElementById){
        newheight=document.getElementById(id).contentWindow.document.body.scrollHeight;
        newwidth=document.getElementById(id).contentWindow.document.body.scrollWidth;
    }
    document.getElementById(id).height= (newheight) + "px";
    document.getElementById(id).width= (newwidth) + "px";
}
</script>

Sunday, July 19, 2015

Load jQuery or JAVAScript when using Update Panel in ASP.net C# or VB.Net

Here are simple 3 steps -

Step 1: Write all javascript or jQuery code inside a function like following-
 
<script> 
function BindIt()
{
    alert("execute again"); 
    //****Add your code here***//
   ----
   -----  
}
</script> 
 
Step 2: Call "BindIt()" function on Body onload event.  
 
<body onload="javascript:BindIt()">
 
Step 3: Add following javascript code inside UpdatePanel..and All Done.. 
 
<form runat="server" ID="form1"> 
 <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
   <asp:UpdatePanel ID="UpdatePanel1" runat="server">
       <ContentTemplate>
          
          <script type="text/javascript">
              Sys.Application.add_load(BindIt);
          </script>