vijay

welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Monday, July 10, 2017

How to get the value from HTML control to code behind?

Here you can find the value from HTML control to code behind using ASP.net

if you still want to get or set values to HTML controls without runat="server" then you can use Request.Form collection to get the value. You can use public property and embedded code blocks to set the value from server. Refer the code below,



ASPX
<input id="txt1" name="txt1" type="text" value="Set in Client Side" />

<input id="txt2" name="txt2" type="text" value="<% =ServerValue %>" />


CodeBehind

public string ServerValue = String.Empty;

protected void btnSave_Click(object sender, EventArgs e)

    {
        string ClientValue = Request.Form["txt1"];
        ServerValue = "Set in Server";
    }
}

Please like .....

Sunday, February 19, 2017

How to Zip and Unzip a file from folder without using opensource in c#

i would like to share the code to zip and unzip a file without using any opensource which is directly used reference file in dot net framework.

Please add the reference file to ZipFile is contained in the assembly System.IO.Compression.FileSystem.
Image result for zip file
To zip a file  
 System.IO.Compression.ZipFile.CreateFromDirectory(startPath, zipPath);
To UnZip a File
 System.IO.Compression.ZipFile.ExtractToDirectory(startPath, extractPath);he reference file to ZipFile is contained in the assembly System.IO.Compression.FileSystem. 

Sunday, July 3, 2016

What is needed to configure a new extension for use in ASP.NET?

Got a question a while back from a customer asking how to enable ASP.NET pages with custom file extensions, so I played around a bit to see how to do it, and here’s what I came up with:
1. Open up the IIS 5.1 or 6 management console, and navigate to the virtual directory (or web site) that you want to configure. Right-click the folder and select Properties.

2. On the Directory (or Web Site) tab, click the Configuration button.

3. On the Mappings tab, click Add, and enter aspnet_isapi.dll (the path is under Windows\Microsoft.net\Framework\<version>\…check the existing mapping for .aspx if you need the exact path) as the Executable, and your desired extension under Extension (I used .foo). Clear the “Check that file exists” box. Click OK (if OK is greyed out, tab around in the textboxes a bit, that usually seems to clear the issue that prevents it from being active). Click OK.

4. In your web.config file (or the main web.config for the machine, if you want this to apply to all sites), add the following HttpHandler mapping (inside the <system.web> tags:

<httpHandlers>

      <add path=”*.foo” verb=”*” type=”System.Web.UI.PageHandlerFactory” validate=”true” />

</httpHandlers>

5. Also in your web.config, add the following Build Provider mapping (goes between the <compilation> tags, you may need to edit the default tag, since in ASP.NET 2.0 it defaults to a self-closing tag):     

<buildProviders>

         <add extension=”.foo” type=”System.Web.Compilation.PageBuildProvider” />

</buildProviders>

The complete <compilation tag should look similar to the following:

<compilation debug=”false” strict=”false” explicit=”true”>

         <buildProviders>

                  <add extension=”.foo” type=”System.Web.Compilation.PageBuildProvider” />

         </buildProviders>

</compilation>

6. Add a new web form to the page (probably easiest to stick with single file pages for this), add controls, etc., and when you’re finished with the page, rename the extension to the one you configured in IIS.

7. Browse with IIS to test.