VS2015 has been launched and if you’re using .net Framework 4.5.2 to create projects using VS2015, you might have noticed that the project templates use Roslyn by default. In this post we will see How To Remove Roslyn support from ASP.NET Project.
If you’re not aware of Roslyn, it is a set of open-source compilers and code analysis APIs for C# and Visual Basic .NET languages from Microsoft. You can see the code here.
Many hosting providers still have not upgraded their servers and hence do not support Roslyn. this is quite common in shared hosting servers. If you upload a project with Roslyn references, you will get unwanted errors on the website. To resolve this issue, we will need to remove Roslyn from the project template. We will see how this can be done in this post.
It’s a 2 step-process to remove Roslyn from your project –
Many times we need to have a textbox on our windows forms where we need to accept only numbers from the end users. .Net does provide us a NumericUpDown control but it is not always handy. In this post, we will see how we can create a TextBox accepting only numbers in Windows Forms for entries.
To enable any TextBox number only, handle the “KeyPress” event handler of the TextBox and write the below code in the handler. Considering the ID of TextBox control is txtNumeric, the code will be like as below –
While working with Access, many times you may get the famous exception “Microsoft.Jet.OLEDB.4.0′ provider is not registered on the local machine“. This normally happens that your code runs fine on your development machine and when you try the run it on production server, this error comes. IN this post, we will see a solution to the same.
This happens because there is no 64 bit version of Jet. To resolve this, you need to do the following steps –
Select the Project in Solution Explorer and right-click on it to open its Properties
Select Build Tab from the Properties window, choose x86 as “Platform Target” on the screen
Save the project & recompile.
Hope this helps you! Keep learning & sharing! Cheers
From the title, this seems to be a very simple post that every novice programmer would know but changing the height of a textbox control in a Windows Forms Application is bit tricky that thought. You must be wondering that setting the Size.Height property of the control would do this, but as soon as you change this, it reverts back to the original default size. If not, go give a try and let me know if it works instantly. In this post, we will see ways on how to achieve this. There are few ways you can increase the height of the textbox. They are –
Option 1: Use MultiLine Property
You can set the MultiLine property of the TextBox control to True and then increase the height of the TextBox. This may not be desirable in some cases when you want to restrict users to enter only single line in the textbox.
Option 2: Change Designer.cs file
Open the Designer.cs file and scroll down to the place where your textbox properties are set. Add the following lines to set the height of the TextBox. However, if you are using this approach, beware that you changes get lost as soon as you make some change in the Form designer and hence this approach is highly recommended to be NOT used.
Option 3: Use MinimumSize Property
This is the most robust way I have found so far. To use this approach, you need to make 2 changes in your Textbox properties.
Set MinimumSize Property of the TextBox to your desired size(Height & Width)
Clear the Size Property of the TextBox to blank and hit Enter.
As you do this, your TextBox will resize to your desired Height & Width.
Hope you like this post! Keep learning and sharing ! Cheers!
In this post, we will see how can we export data from GridView to Excel 2007/2010 format in ASP.Net in less than 5 minutes. Without much delay, let’s get started –
Add EPPlus package using Nuget.
Include OfficeOpenXml and OfficeOpenXml.Table namespaces at the top.
In your event handler, write the below code.
Response.Charset = ""
Response.ContentEncoding = System.Text.Encoding.UTF8
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Dim dt As DataTable = CType(gridView.DataSource, DataTable)
Using pck As New ExcelPackage()
Dim wsDt As ExcelWorksheet = pck.Workbook.Worksheets.Add("Sheet1")
wsDt.Cells("A1").LoadFromDataTable(dt, True, TableStyles.None)
In the above code, what we are doing is first of all, clearing the Response and setting the ContentType and Header for the Response object. This is to be noted that “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet” is the type to be set for Excel 2007. Once these are set, we are getting the Data Source of the GridView in a DataTable. Then, we use an object of ExcelPackage class to create a worksheet and load the DataTable into the worksheet from Cell A1. Calling the AutoFitColumns() ensures that the Excel file written is auto set to fit the column contents. Once the data is written and the excel file is created in memory, we write the same back to the browser. This allows users to either open the Excel file or save it their hard disks.
Hope you like this post! Keep learning & sharing! Cheers!
If you like this site please help and make click on any of these buttons!