<html> <body> <table> <tr><td>Text to Save:</td></tr> <tr> <td colspan="3"> <textarea id="inputTextToSave" style="width:512px;height:256px"></textarea> </td> </tr> <tr> <td>Filename to Save As:</td> <td><input id="inputFileNameToSaveAs"></input></td> <td><button onclick="saveTextAsFile()">Save Text to File</button></td> </tr> <tr> <td>Select a File to Load:</td> <td><input type="file" id="fileToLoad"></td> <td><button onclick="loadFileAsText()">Load Selected File</button><td> </tr> </table> <script type='text/javascript'> function saveTextAsFile() { var textToWrite = document.getElementById("inputTextToSave").value; var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'}); var fileNameToSaveAs = document.getElementById("inputFileNameToSaveAs").value; var downloadLink = document.createElement("a"); downloadLink.download = fileNameToSaveAs; downloadLink.innerHTML = "Download File"; if (window.webkitURL != null) { // Chrome allows the link to be clicked // without actually adding it to the DOM. downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob); } else { // Firefox requires the link to be added to the DOM // before it can be clicked. downloadLink.href = window.URL.createObjectURL(textFileAsBlob); downloadLink.onclick = destroyClickedElement; downloadLink.style.display = "none"; document.body.appendChild(downloadLink); } downloadLink.click(); } function destroyClickedElement(event) { document.body.removeChild(event.target); } function loadFileAsText() { var fileToLoad = document.getElementById("fileToLoad").files[0]; var fileReader = new FileReader(); fileReader.onload = function(fileLoadedEvent) { var textFromFileLoaded = fileLoadedEvent.target.result; document.getElementById("inputTextToSave").value = textFromFileLoaded; }; fileReader.readAsText(fileToLoad, "UTF-8"); } </script> </body> </html>
Here you will find about .net technology. also can get example about MVC.net and jquery.
Monday, January 20, 2014
Loading, Editing, and Saving a Text File in HTML5 Using Javascript
Simple way to export SQL Server data to Text Files
EXEC xp_cmdshell 'bcp "SELECT * FROM ACESRepView.Users.XmlData" queryout "d:\data.txt" -S "server name" -U username -P passwrd -c'
write text file in sql server 2008
DECLARE @cmd varchar(256), @var varchar(50)
SET @var = 'Hello world!' +CHAR(13)+CHAR(10)+ 'This is second line'
print @var
SET @cmd = 'echo>d:\myfile.txt ' + @var
EXEC master..xp_cmdshell @cmd, no_output
SET @var = 'Hello world!' +CHAR(13)+CHAR(10)+ 'This is second line'
print @var
SET @cmd = 'echo>d:\myfile.txt ' + @var
EXEC master..xp_cmdshell @cmd, no_output
Enable 'xp_cmdshell' SQL Server
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO
Saturday, January 18, 2014
Export HTML to Excel ap.net c#
aspx page code
<form id="form1" runat="server">
<div>
<div runat="server" id="ExportDiv">
<span class="SubSectionHeading">First Table:</span><table rules="all" cellspacing="0"
cellpadding="3" width="922">
<tr>
<th width="200px">
Item Name
</th>
<th width="100px">
Price
</th>
<th width="100px">
Market Price
</th>
<th width="100px">
Actual Price
</th>
<th width="100px">
Difference
</th>
<th width="200px">
Notes
</th>
</tr>
<tr>
<td>
Item 1
</td>
<td>
€78.00
</td>
<td>
€67.00
</td>
<td>
€67.00
</td>
<td>
€0.00
</td>
<td>
description of Item
</td>
</tr>
<tr>
<td>
Item 2
</td>
<td>
€90.00
</td>
<td>
€789.00
</td>
<td>
€90.00
</td>
<td>
-€699.00
</td>
<td>
description of Item
</td>
</tr>
<tr>
<td>
Item 3
</td>
<td>
€900.00
</td>
<td>
€700.00
</td>
<td>
€8.00
</td>
<td>
-€692.00
</td>
<td>
description of Item
</td>
</tr>
<tr>
<td>
Item 4
</td>
<td>
€789.00
</td>
<td>
€78.00
</td>
<td>
€980.00
</td>
<td>
€902.00
</td>
<td>
description of Item
</td>
</tr>
<tfoot>
<tr>
<td style="text-align: center;">
Table 1 Total
</td>
<td>
€1,857.00
</td>
<td>
€1,634.00
</td>
<td>
€1,145.00
</td>
<td>
-€489.00
</td>
<td>
</td>
</tr>
<tfoot>
</table>
</br><span class="SubSectionHeading">Second Table:</span><table rules="all" cellspacing="0"
cellpadding="3" width="922">
<tr>
<tr>
<th width="200px">
Item Name
</th>
<th width="100px">
Price
</th>
<th width="100px">
Market Price
</th>
<th width="100px">
Actual Price
</th>
<th width="100px">
Difference
</th>
<th width="200px">
Notes
</th>
</tr>
<tr>
<td>
Item 1
</td>
<td>
€45.00
</td>
<td>
€67.00
</td>
<td>
€8.00
</td>
<td>
-€59.00
</td>
<td>
description of Item
</td>
</tr>
<tr>
<td>
Item 2
</td>
<td>
€600.00
</td>
<td>
€899.00
</td>
<td>
€65.00
</td>
<td>
-€834.00
</td>
<td>
description of Item
</td>
</tr>
<tr>
<td>
Item 3
</td>
<td>
€7.00
</td>
<td>
€9.00
</td>
<td>
</td>
<td>
</td>
<td>
description of Item
</td>
</tr>
<tr>
<td>
Item 4
</td>
<td>
€78.00
</td>
<td>
€90.00
</td>
<td>
€67.00
</td>
<td>
-€23.00
</td>
<td>
description of Item
</td>
</tr>
<tr>
<td>
Item 5
</td>
<td>
€789.00
</td>
<td>
€980.00
</td>
<td>
€67.00
</td>
<td>
-€913.00
</td>
<td>
description of Item
</td>
</tr>
<tr>
<td>
Item 6
</td>
<td>
€6.00
</td>
<td>
€6.00
</td>
<td>
€78.00
</td>
<td>
€72.00
</td>
<td>
description of Item
</td>
</tr>
<tfoot>
<tr>
<td style="text-align: center;">
Table 2 Total
</td>
<td>
€1,525.00
</td>
<td>
€2,051.00
</td>
<td>
€285.00
</td>
<td>
-€1,757.00
</td>
<td>
</td>
</tr>
<tfoot>
</table>
</br><span class="SubSectionHeading">Total:</span><table rules="all" cellspacing="0"
cellpadding="3" class="rgMasterTableTotal" width="630">
<tr>
<th width="200px">
Table
</th>
<th width="100px">
Price
</th>
<th width="100px">
Market Price
</th>
<th width="100px">
Actual Price
</th>
<th width="100px">
Difference
</th>
</tr>
<tr>
<td style="text-align: center;">
Table 1
</td>
<td>
€1,857.00
</td>
<td>
€1,634.00
</td>
<td>
€1,145.00
</td>
<td>
-€489.00
</td>
</tr>
<tr>
<td style="text-align: center;">
Table 2
</td>
<td>
€1,525.00
</td>
<td>
€2,051.00
</td>
<td>
€285.00
</td>
<td>
-€1,757.00
</td>
</tr>
<tfoot>
<tr style="background-color: #404040; color: White;">
<td style="text-align: center;">
Grand Total
</td>
<td>
€3,382.00
</td>
<td>
€3,685.00
</td>
<td>
€1,430.00
</td>
<td>
-€2,246.00
</td>
</tr>
<tfoot>
</table>
</div>
<asp:Button runat="server" ID="ExportToExcelButton" OnClick="ExportToExcelButton_Click"
Text="Export To Excel" />
</div>
</form>
--------------------------------------------------------------
code hehind
protected void ExportToExcelButton_Click(object sender, EventArgs e)
{
Response.AppendHeader("content-disposition", "attachment;filename=ExportedHtml.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";
this.EnableViewState = false;
Response.Write(ExportDiv.InnerHtml);
Response.End();
}
<form id="form1" runat="server">
<div>
<div runat="server" id="ExportDiv">
<span class="SubSectionHeading">First Table:</span><table rules="all" cellspacing="0"
cellpadding="3" width="922">
<tr>
<th width="200px">
Item Name
</th>
<th width="100px">
Price
</th>
<th width="100px">
Market Price
</th>
<th width="100px">
Actual Price
</th>
<th width="100px">
Difference
</th>
<th width="200px">
Notes
</th>
</tr>
<tr>
<td>
Item 1
</td>
<td>
€78.00
</td>
<td>
€67.00
</td>
<td>
€67.00
</td>
<td>
€0.00
</td>
<td>
description of Item
</td>
</tr>
<tr>
<td>
Item 2
</td>
<td>
€90.00
</td>
<td>
€789.00
</td>
<td>
€90.00
</td>
<td>
-€699.00
</td>
<td>
description of Item
</td>
</tr>
<tr>
<td>
Item 3
</td>
<td>
€900.00
</td>
<td>
€700.00
</td>
<td>
€8.00
</td>
<td>
-€692.00
</td>
<td>
description of Item
</td>
</tr>
<tr>
<td>
Item 4
</td>
<td>
€789.00
</td>
<td>
€78.00
</td>
<td>
€980.00
</td>
<td>
€902.00
</td>
<td>
description of Item
</td>
</tr>
<tfoot>
<tr>
<td style="text-align: center;">
Table 1 Total
</td>
<td>
€1,857.00
</td>
<td>
€1,634.00
</td>
<td>
€1,145.00
</td>
<td>
-€489.00
</td>
<td>
</td>
</tr>
<tfoot>
</table>
</br><span class="SubSectionHeading">Second Table:</span><table rules="all" cellspacing="0"
cellpadding="3" width="922">
<tr>
<tr>
<th width="200px">
Item Name
</th>
<th width="100px">
Price
</th>
<th width="100px">
Market Price
</th>
<th width="100px">
Actual Price
</th>
<th width="100px">
Difference
</th>
<th width="200px">
Notes
</th>
</tr>
<tr>
<td>
Item 1
</td>
<td>
€45.00
</td>
<td>
€67.00
</td>
<td>
€8.00
</td>
<td>
-€59.00
</td>
<td>
description of Item
</td>
</tr>
<tr>
<td>
Item 2
</td>
<td>
€600.00
</td>
<td>
€899.00
</td>
<td>
€65.00
</td>
<td>
-€834.00
</td>
<td>
description of Item
</td>
</tr>
<tr>
<td>
Item 3
</td>
<td>
€7.00
</td>
<td>
€9.00
</td>
<td>
</td>
<td>
</td>
<td>
description of Item
</td>
</tr>
<tr>
<td>
Item 4
</td>
<td>
€78.00
</td>
<td>
€90.00
</td>
<td>
€67.00
</td>
<td>
-€23.00
</td>
<td>
description of Item
</td>
</tr>
<tr>
<td>
Item 5
</td>
<td>
€789.00
</td>
<td>
€980.00
</td>
<td>
€67.00
</td>
<td>
-€913.00
</td>
<td>
description of Item
</td>
</tr>
<tr>
<td>
Item 6
</td>
<td>
€6.00
</td>
<td>
€6.00
</td>
<td>
€78.00
</td>
<td>
€72.00
</td>
<td>
description of Item
</td>
</tr>
<tfoot>
<tr>
<td style="text-align: center;">
Table 2 Total
</td>
<td>
€1,525.00
</td>
<td>
€2,051.00
</td>
<td>
€285.00
</td>
<td>
-€1,757.00
</td>
<td>
</td>
</tr>
<tfoot>
</table>
</br><span class="SubSectionHeading">Total:</span><table rules="all" cellspacing="0"
cellpadding="3" class="rgMasterTableTotal" width="630">
<tr>
<th width="200px">
Table
</th>
<th width="100px">
Price
</th>
<th width="100px">
Market Price
</th>
<th width="100px">
Actual Price
</th>
<th width="100px">
Difference
</th>
</tr>
<tr>
<td style="text-align: center;">
Table 1
</td>
<td>
€1,857.00
</td>
<td>
€1,634.00
</td>
<td>
€1,145.00
</td>
<td>
-€489.00
</td>
</tr>
<tr>
<td style="text-align: center;">
Table 2
</td>
<td>
€1,525.00
</td>
<td>
€2,051.00
</td>
<td>
€285.00
</td>
<td>
-€1,757.00
</td>
</tr>
<tfoot>
<tr style="background-color: #404040; color: White;">
<td style="text-align: center;">
Grand Total
</td>
<td>
€3,382.00
</td>
<td>
€3,685.00
</td>
<td>
€1,430.00
</td>
<td>
-€2,246.00
</td>
</tr>
<tfoot>
</table>
</div>
<asp:Button runat="server" ID="ExportToExcelButton" OnClick="ExportToExcelButton_Click"
Text="Export To Excel" />
</div>
</form>
--------------------------------------------------------------
code hehind
protected void ExportToExcelButton_Click(object sender, EventArgs e)
{
Response.AppendHeader("content-disposition", "attachment;filename=ExportedHtml.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";
this.EnableViewState = false;
Response.Write(ExportDiv.InnerHtml);
Response.End();
}
Set "everyone" Permission to Folder using C# in Asp.Net
string redirectionFolder = @"D:\test\subtest\";
FileSystemAccessRule everyOne = new FileSystemAccessRule("Everyone", FileSystemRights.FullControl,AccessControlType.Allow);
DirectorySecurity dirSecurity = new DirectorySecurity(redirectionFolder, AccessControlSections.Group);
dirSecurity.AddAccessRule(everyOne);
Directory.SetAccessControl(redirectionFolder, dirSecurity);
Note:
If you get the error "Attempted to perform an unauthorized operation"
add the tag (<identity impersonate="true"/>) in your web.config file.
FileSystemAccessRule everyOne = new FileSystemAccessRule("Everyone", FileSystemRights.FullControl,AccessControlType.Allow);
DirectorySecurity dirSecurity = new DirectorySecurity(redirectionFolder, AccessControlSections.Group);
dirSecurity.AddAccessRule(everyOne);
Directory.SetAccessControl(redirectionFolder, dirSecurity);
Note:
If you get the error "Attempted to perform an unauthorized operation"
add the tag (<identity impersonate="true"/>
Window Service in Studio 2010
1) Create New Project ("WindowsService")
2) Open Service1.cs => press f4 key
you will see property of service1.cs
3) Below Property box you will see Add Installer Option => Click there
you will see ProjectInstaller.cs file in solution explorer
4) Now open ProjectInstaller.cs
you will see two option there
one is serviceProcessInstaller1
second is serviceInstaller1
5) Right click on serviceInstaller1 and select property
in property box set StartType = Manual
6) Now build your solution
7) Now , go to All programe => visual studio => visual studio tools => visual studio command prompt , Right click there Run As Administrator
8) go your Root path where your project located
now type this line C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\InstallUtil.exe or InstallUtil.exe
then type windowservice.exe
give Enter
9) Now Press Win+R key and type services.msc
Find Service Name windowservice.exe
Right click on it and Start it.
Subscribe to:
Posts (Atom)
Opps Part 1 : Abstraction
Abstraction in C# is a fundamental concept of object-oriented programming (OOP) that allows developers t...
-
<html> <body> <table> <tr><td>Text to Save:</td></tr> <tr> <td colspan="3...
-
SQL Server has several fixed database roles such as db_datareader and db_datawriter , which grants the user read and write access res...
-
Get Yahoo Contact for C# Create new Website Create AppCode Folder Create OAuthBase.cs in AppCode Folder like us...