Saturday, August 10, 2013

Use of Sub Query in Asp.Net

Sub Query

1)StateMaster Table

Column Name:-Id,State

2)CityMaster Table

Column Name:- Id,StateId,City

Question:- How to retrieve Column City,State from Table CityMaster,StateMaster respectively?

Answer:- select *,(select [State] from StateMaster where StateMaster.Id=StateId) as [State] from CityMaster 




Tuesday, May 28, 2013

Required Field Validation for Ajax Combobox

Required field validation not working with Ajax combobox

Reason:-

Combobox doesn't rendered as a dropdownlist. Infact,it is interpreted as a textbox.So,required field validation with initial value attritube="(selected value)" will not work.It required to set initial 
value = "--Select--"  in order for combobox satisfied your required field validation.

<asp:ComboBox ID="ComboEMINo" runat="server"  AutoPostBack="true" >
</asp:ComboBox>
 <asp:RequiredFieldValidator ID="rfvEMINo" ControlToValidate="ComboEMINo" runat="server"
 ErrorMessage="Select EMINo." ForeColor="Red" InitialValue="--Select--">*</asp:RequiredFieldValidator>


Thursday, February 28, 2013

How to put Asp.net site under maintainence

Placed Live Asp.net site under maintainence or monitering
Firstly create App_Offline.htm file in the root of your asp.net website.Define your markup for the end user to display in this file when your live website is under maintainence or monitering session.Now,whenever you view any of your website page it will show code on your App_Offline.htm file.

After ajaxify the pages gridview rowcommand event not firing on page refresh

Problem:
I have an .aspx where i am loading gridview data for the first time using (!ispostback).On the same page i have a linkbutton which fires a Modelpopup extender which has a target id of panel which includes two textbox,one file upload and two button controls.In the gridview i have two button column for edit and delete.But when i load the page for the first time,gridview rowcommand is not firing.
1)So,how should i wrap the code in order to fire the gridview rowcommand events.
2)In the panel i have two button controls and none of there click is binding to the code behind.so how to fire these two controls events.
Please mention your valuable comments and help me out.

Wednesday, January 16, 2013

Mystery behind app_offline.htm file is solved!!!


What is app_offline.htm file?
Asp.net framework avail offline mode of web application to perform some update and data transfer operation on production server.In offline mode application does not respond to request made for dynamic web page.So,when a request for web page is made from an application in offline mode,it return error message to the user which states:

"This application is currently offline.To enable the application, remove the app_offline.htm file from the application root directory."

Above error message is returned to user using app_offline.htm file.Therefore,app_offline.htm file is used to send customized error message to all user who request dynamic pages from application in offline mode.

How app_offline.htm file is created?
SQL Server 2005 express edition and its superceded editions does not support multiple processes.Only single process can access database at a one time.So,when database is accessed through visual studio, visual studio's integrated web server,also known as cassini cannot access database.This will result to internal server error.To prevent these,visual studio places app_offline.htm file under the root of your web application,which put your application in offline mode.










Tuesday, January 15, 2013

What is DataDirectory in Asp.net?

In Asp.net, DataDirectory (which is enclosed in a pipe symbol in a connection string) is a replacement string which indicate path to your database file and also eliminate the need to hard-code the full path to your database file as .

By default DataDirectory refers to  App_Data folder under the root of your web application.For Desktop application, DataDirectory points to bin directory.So,now the question is what is we wanted DataDirectory to point to a different location(other than App_Code folder)?

The issue can be resolved using AppDomain.And the following line will set DataDirectory path before using it in connection string.

AppDomain.CurrentDomain.setData("DataDirectory",@"c:\Data\");

That would make your DataDirectory to point to "c:\Data\database.mdf path.