"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Monday, October 22, 2012

Print a div or grid in javascript

 Hi *.*,
 

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Print Gridview Data in asp.net</title>
<script type="text/javascript">
function PrintGridData() {
var prtGrid = document.getElementById('<%=gvUserInfo.ClientID %>');
prtGrid.border = 0;
var prtwin = window.open('', 'PrintGridViewData', 'left=100,top=100,width=1000,height=1000,tollbar=0,scrollbars=1,status=0,resizable=1');
prtwin.document.write(prtGrid.outerHTML);
prtwin.document.close();
prtwin.focus();
prtwin.print();
prtwin.close();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<b>Print Gridview Data</b><br /><br />
<asp:GridView ID="gvUserInfo" runat="server" >
<HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White"/>
</asp:GridView>
<input type="button" id="btnPrint" value="Print" onclick="PrintGridData()" />
</div>
</form>
</body>
</html>




If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)

Sunday, October 21, 2012

Limit access by IP with web.config

Web.config ipSecurity
The web.config file can be used to restrict website access, by the client IP address. Web.config can be used to restrict access to a single page, a directory and all sub directories, or even the entire web site. You can block all IP addresses and only let a few trusted IP addresses in, or you could allow everyone and block specific IP addresses or subnets.

While some web.config sections require that the containing directory is set as an application, this isn't one of them. A simple web.config with a ipSecurity section may be placed in any directory, and the directory does NOT need to be set as an application.
Purpose
IP address restrictions are used to restrict access based on the IP address of the client computer. IP address restrictions can be used to protect specific directories, or the entire web site. IP address restrictions can be used with two methods.

    Allow all, but block specific IPs or networks
    Deny all, but allow specific IPs or networks

How it's done
Example IP address restrictions. Comments are enclosed in <!-- --> and are not required.

    Allow all, but block specific IPs or networks

    <security>
       <ipSecurity allowUnlisted="true">    <!-- this line allows everybody, except those listed below -->           
           <clear/>     <!-- removes all upstream restrictions -->               
           <add ipAddress="83.116.19.53"/>     <!-- blocks the specific IP of 83.116.19.53  -->               
           <add ipAddress="83.116.119.0" subnetMask="255.255.255.0"/>     <!--blocks network 83.116.119.0 to 83.116.119.255-->               
           <add ipAddress="83.116.0.0" subnetMask="255.255.0.0"/>     <!--blocks network 83.116.0.0 to 83.116.255.255-->               
           <add ipAddress="83.0.0.0" subnetMask="255.0.0.0"/>     <!--blocks entire /8 network of 83.0.0.0 to 83.255.255.255-->               
       </ipSecurity>
    </security>


    Deny all, but allow specific IPs or networks

    <security>
        <ipSecurity allowUnlisted="false">    <!-- this line blocks everybody, except those listed below -->               
            <clear/> <!-- removes all upstream restrictions -->
            <add ipAddress="127.0.0.1" allowed="true"/>    <!-- allow requests from the local machine -->
            <add ipAddress="83.116.19.53" allowed="true"/>   <!-- allow the specific IP of 83.116.19.53  -->               
            <add ipAddress="83.116.119.0" subnetMask="255.255.255.0" allowed="true"/>   <!--allow network 83.116.119.0 to 83.116.119.255-->               
            <add ipAddress="83.116.0.0" subnetMask="255.255.0.0" allowed="true"/>   <!--allow network 83.116.0.0 to 83.116.255.255-->               
            <add ipAddress="83.0.0.0" subnetMask="255.0.0.0" allowed="true"/>   <!--allow entire /8 network of 83.0.0.0 to 83.255.255.255-->               
        </ipSecurity>
    </security>


Using IP Address Restrictions

    Use a text editor to create a file named web.config
    Save the web.config file with the appropriate content
    Place the web.config file in the directory that you wish to protect


Detailed web.config content

    If there isn't an existing web.config in the directory, your new web.config should look something like this

    <?xml version="1.0"?>
    <configuration>
       <system.webServer>
          <security>
            <ipSecurity allowUnlisted="true">    <!-- this line blocks everybody, except those listed below -->               
               <clear/> <!-- removes all upstream restrictions -->
               <add ipAddress="83.116.19.53"/>   <!-- block one IP  -->               
               <add ipAddress="83.116.119.0" subnetMask="255.255.255.0"/>   <!--block network 83.116.119.0 to 83.116.119.255-->              
            </ipSecurity>
          </security>
          <modules runAllManagedModulesForAllRequests="true"/>
       </system.webServer>
    </configuration>


    If there is an existing web config, without a <system.webServer> section... Your new web.config should look like this

    <?xml version="1.0"?>
    <configuration>
       <system.web>
         .. existing text ..
         .. existing text ..
       </system.web>
       <system.webServer>
          <security>
            <ipSecurity allowUnlisted="true">    <!-- this line blocks everybody, except those listed below -->               
               <clear/> <!-- removes all upstream restrictions -->
               <add ipAddress="83.116.19.53"/>   <!-- block one IP  -->               
               <add ipAddress="83.116.119.0" subnetMask="255.255.255.0"/>   <!--block network 83.116.119.0 to 83.116.119.255-->              
            </ipSecurity>
          </security>
          <modules runAllManagedModulesForAllRequests="true"/>
       </system.webServer>
    </configuration>


    If your existing web.config already has a <system.webServer> section, just add the <security><ipSecurity> section

    <?xml version="1.0"?>
    <configuration>
       <system.web>
         .. existing text ..
         .. existing text ..
       </system.web>
       <system.webServer>
          <security>
            <ipSecurity allowUnlisted="true">    <!-- this line blocks everybody, except those listed below -->               
               <clear/> <!-- removes all upstream restrictions -->
               <add ipAddress="83.116.19.53"/>   <!-- block one IP  -->               
               <add ipAddress="83.116.119.0" subnetMask="255.255.255.0"/>   <!--block network 83.116.119.0 to 83.116.119.255-->              
            </ipSecurity>
          </security>
          <modules runAllManagedModulesForAllRequests="true"/>
       </system.webServer>
    </configuration>

 




If u had any trouble just ask, Happy to help u :) 
Stay Tune...
 Have a nice day... 'N happy Coding :)

Friday, October 12, 2012

Merging two table of different data types.

 Hi *.*,

Merging two table of different data types.

                table1.Merge(table2, false, MissingSchemaAction.Ignore); 
                ds.Tables.Add(table1);  // Moving table to a dataset


If u had any trouble just ask,
 Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)