While working smoothly on ASP.NET, sometimes the page would stop responding to the server and plate ‘offline’ at the top. Some controls like calendar would stop responding while selecting the date.
For this problem, the solution is easy – just go to file menu of IE and uncheck ‘work offline’ – good to go!
Processing File Before Upload
You can manage size before upload by messing web.config’s maxRequestLength attribute and
you can also validate and cancel posting of the form using customvalidation control and you can write what ever logic on the customValidator’s code part
A more nice approach can be found here http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.saveas.aspx
Server.Transfer() and Response.Redirect()
Working on my current project, I come up with a scenario to switch a visitor to a new page after some process.
Here I have an option to use either redirect() or server.transfer(). So what are the tradeoffs:
- Redirect() would allow to navigate to other pages out of the current website unlike Transfer()
- Redirect() needs a round-trip to client page but transfer() won’t need this which would make transfer() a bit fast
Well for my case, I am not redirecting to other page and I want it to be fast so – I have used Server.Transfer().
For questions related to page transfer refer http://msdn.microsoft.com/en-us/library/x3x8t37x.aspx
What is PostBack in ASP.NET
Postback in simple terms is self referal of the page. In earlier version of ASP, the form would ‘POST’ values to another page for validation or some process using the post method.
But in ASP.NET, the page which accepts the values through its form would be responsible for validating/processing the values.
More @ http://www.codersource.net/asp_net_post_back.html
How to add and drop primary key in SQL Server
If you want to add primary key after you create the table in the sql server, then
1. go to Microsoft SQL Server Management Studio
2. Right click on the database and select new query
3. ALTER TABLE tbl_name ADD PRIMARY KEY(pr_key_column);
tbl_name – name of the table you want to assign primary key
pr_key_column – column/field name which you want it to be primary key
If the pr_key_column is allowed null values, then you can’t assign it as primary key. So if that is the case use this query first:
ALTER TABLE tbl_name ALTER COLUMN pr_key_column datatype not null;
To revoke primary key:
ALTER TABLE tbl_name DROP CONSTRAINT(pr_key_column);
Constraints in SQL Server
A good examples on constraints can be found here:
http://www.mssqlcity.com/Articles/General/using_constraints.htm
What is the difference between NCHAR, CHAR, NVARCHAR and VARCHAR
A good information with explanation is found here
http://www.sql-server-helper.com/faq/data-types-p01.aspx
Previous releases of Microsoft Visual Studio 2008 failed error
While you are trying to install MS SQL Server 2008 on the machine which already has Visual studio, you might come up with this problem.
Here is the remedy.
Go to command prompt and move to the MS SQL Server installation DVD like:
C:…>E: – assuming your DVD drive letter is ‘E’
Then provide the following command:
SETUP /action=install /skiprules=vsshellinstalledrule
While you are installing, you might come up with error message but pass it selecting ok.
The other solution might be the trivial one – uninstall VS and install MS SQL Server then install VS –
I hope it will help a lot.
How to move MySQL database from one server to another
First access the files of the database (MYI, MYD, FRM) from the existing database by going to
/var/lib/mysql/(your database) – This path holds true for ubuntu
Then go to the new server and put it in the same place
/var/lib/mysql/(your database).
restart your server and mysql then view it through phpmyadmin.
How to change default MySQL directory
Originally it will be located at /var/lib/mysql
Say you want to change it to /home/myApps/mysql
First if the mysql is running stop it: sudo /etc/init.d/mysql stop
and stop the server too: sudo/etc/init.d/apache2 stop
Go to /etc/mysql/my.cnf and edit:
datadir = /var/lib/mysql to datadir = /home/myApps/mysql
Copy files from existing path to the new path
cp -R /var/lib/mysql* /home/myApp/mysql
Grant ownership to new directory for mysql
sudo chown -R mysql:mysql /home/myApp/mysql
then start up your server and mysql – voila.