Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Link Building

Tuesday, May 18, 2010

AJAX : Beware of following Controls in ASP.Net

The following ASP.NET controls are not compatible with partial-page updates, and are therefore not supported inside an UpdatePanel control:
  • TreeView 
  • Menu controls.
  • FileUpload controls.
  • GridView and DetailsView controls when their EnableSorting And Paging property is set to true.
  • Login, PasswordRecovery, ChangePassword, and CreateUserWizard controls whose contents have not been converted to editable templates.
  • Validation controls
  • It includes the BaseCompareValidator, BaseValidator, CompareValidator, CustomValidator, RangeValidator, RegularExpressionValidator, RequiredFieldValidator, and ValidationSummary control. 
 Also i come to know that u cant do a partial update inside a repeter control.

Tuesday, March 30, 2010

ASP.Net Authentication And Authorization for javascript ,Image and CSS

Authentication means figuring out who you are and Authorization means figuring out what you can do. Both are fundamental parts of the ASP.NET Security Model.

One thing to notice in ASP.NET authentication mechanism is that ASP.NET authenticates requests for resources such as .aspx, .asmx, .ashx, .axd, .ascx and others that are mapped to the ASP.NET ISAPI DLL (aspnet_isapi.dll). ASP.NET does not authenticate requests for images (GIF, JPEG, etc), CSS or JavaScript files. If you want these resources also to be secured by ASP.NET (Forms Authentication, Windows Authentication or Passport), add them to the list of ASP.NET ISAPI mappings. This can be done from the Internet Information Services Manager (IIS Manager) by following these steps:
  1. Open IIS Manager (Start/Run, type inetmgr and Enter)
  2. From the left-side tree view, select the web application you want to change the mappings for
  3. Right-click on the web application and select Properties
  4. Swirch to Home Directory Tab and click Configuration
  5. On the Mappings tab, click Add and enter the extension (one of .js, .css, .jpeg) and ASP.NET ISAPI DLL path for Executable. You can copy/paste the complete path to the ISAPI DLL from any other mapping, .aspx, for example.
  6. Repeat the above step for other file extensios too, if required
  7. Click OK thrice  
Once done, requests to non-ASP.NET resources will also be subjected to ASP.NET authentication. The downside of this approach however is that it negatively impacts the performance of the web application because ASP.NET has to authenticate additional resource requests.

Monday, June 22, 2009

Abstract and virtual function and class in C#

i always find abstract and virtual as confusing. so i decided to do all test and write my experience of the same.I have consider all the angles, where a smart interviewer can trap you.
Most of the time the first question an interviewer ask is whats difference between abstract and virtual method in C#.

The simplest difference is that , body is needed for virtual function where it is declare, where as its just opposite in case of abstract function.

Lets examine this example

The first class is abstract class which contains a abstract method inabs()
if we give body to this method then it will give compile time error saying "cannot declare a body Function is marked as abstract".

Making a function abstract compels the inheriting class to define the abstract function.


 
public abstract class abstractparent {
public abstract void inabs();
public void noabsparent()
{
Console.WriteLine("In Class Contaning abstract methode");
}
}
public class abstractchild : abstractparent {
public void noabschild()
{
Console.WriteLine("In Child class of Abstract Parent");
}
public override void inabs()
{
Console.WriteLine("In Child class functin definition of abstract");
}
}



Also when we are declaring a abstract function in a class its necessary to use ABSTRACT keyword with class and function both.
A non abstract class can't contain the abstract method.if we defined a abstract method in non abstract class and try to compile it then it will give compile time error stating "A non abstract class has abstract function".you can check it by altering the above classes.

In virtual function we must have to specify the body of the virtual function.if we not specify the body then it will give compile time error stating "must declare a body because it is not marked as abstract, extern or partial".



#region virtual_function
class virtual_parent
{
public virtual void vir_parent()
{
Console.WriteLine("IN vir_parent function of parent class which is defiend in parent class");
}
public void non_vir_parent()
{
Console.WriteLine("IN non_vir_parent function of parent class which is defiend in parent class");
}
}
class virtual_child:virtual_parent
{
new public void non_vir_parent()
{
Console.WriteLine("IN non_vir_parent function of CHILD class which is defiend in CHILD class");
}
public override void vir_parent()
{
Console.WriteLine("IN vir_parent function of CHILD class which is defiend in CHILD class");
//base.vir_parent();
}
}
#endregion




Some tricky question interviewer may ask you.

1)Can we declare and defined a normal(not abstract, virtual,extern or partial) function in derived class which is already present in base class.
Yes we can do this in dotnet.
By using new keyword we can re-declare and redefine a normal function in drived class. for detail please refer the above code.

2)If above is true then how you will call the base class function by using child class object.

this we can do by explicitly type casting the base class object in to parent class

Use this code to see the result
virtual_child obj_virtual_child = new virtual_child();
((virtual_parent)obj_virtual_child).non_vir_parent();

I hope i have covered all the expect of the virtual and abstract.please let me know if any body have any query.
please also let me know if any body have problem in any concept of dotnet.
You can reach me at rajhan143-hostway@yahoo.co.in

Tuesday, December 25, 2007

how to create colon of a existing table

we often require colon of table to take backup .Creating colon of table in different database requires different queries.these colons are used for temporary data manipulation. Some of the different queries used in different database are explain below.


MySql
CREATE TABLE new_table_name like existing_table_name
this will create new table with all the property of old table (like primary key , auto increment)

CREATE TABLE new_table_name select * from old_table
this query will create new table with all data and and structure but property like primary key are drooped
CREATE TABLE new_table_name (ID INT auto_increment primary key ) select * from old_table
this query will create new table with old table structure and with a new column " ID " .
if ID exist in old table then it will assign the property of primary key and auto increment to ID column;


ORACLE
CREATE TABLE newTable AS SELECT * FROM oldTable WHERE 1= 2;
This will create table newTable with the same columns as oldTable.
It will have no constraints or indexes. It will have zero(o) rows in it.
CREATE TABLE newTable AS SELECT * FROM oldTable WHERE 1= 1;
OR
CREATE TABLE newTable AS SELECT * FROM oldTable;
This will create table newTable with the same columns as oldTable and with all data of old table.

SQL 2000
SELECT * INTO emp_new from emp where 1=2
This will create the table structure alone.
SELECT * INTO emp_new from emp where 1=1
This will create the table structure with data.

Tuesday, December 4, 2007

Pass Multiple Arguments to Function

In our day to day programing life we find some situation when we need to pass multiple arguments at run time . we dont know the number of arguments to be passed by the user.

JavaScript
I find javaScript more handy. JavaScript provide a special property called " arguments " which contains the array of arguments passed to the function.
we can take this in an array and by length property of array we know the number of arguments passed.


function myFunc()
{
var arguments = myFunc.arguments;
for (var i = 0; i < arguments.length; i++) {
alert("Argument number " + i + " value = " + arguments[i]);
}
}

This function can be called with any number of arguments at the runtime like
vikFunc('neeraj', 'raju');
vikFunc('neeraj', 'raju','vinay','amole');

C++

In c++ we use '...'(three dots) for passing multiple arguments.The first argument of the function represents the number of argument to be passed and the second argument '...'(three dots) represents the values to be passed.First argument is int and second argument could be any thing like int, double etc .....

we also need four things va_list which stores the arguments , va_start which initializes the list , va_arg which returns the arguments in the list and va_end which cleans up the
variable in the list. To get these we must include the “cstdarg ” header file.

va_list is like any other variable.

va_start is a macro which accepts two arguments, a va_list and the name of the variable that directly precedes the '...'(three dots ) . So, in the function a_function, to initialize a_list with va_start, you would write va_start ( a_list, x );

va_arg takes a va_list and a variable type, and returns the next argument in the list in the form of whatever variable type it is told. It then moves down the list to the next argument.

#include
#include
using namespace std;

double average ( int num, ... )
{
va_list arguments; // A place to store the list of arguments
double sum = 0;
va_start ( arguments , num ); // Initializing arguments to store all values after num
for ( int x = 0; x < num; x++ ) // Loop until all numbers are added
sum += va_arg ( arguments, double ); // Adds the next value in argument list to
sum. va_end ( arguments );
// Cleans up the list
return sum / num; // Returns some number
}
int main()
{
cout<< average ( 3, 12.2, 22.3, 4.5 );
cout<< average(5,3.3,2.3,3.5,6.7,2.9);
}

Thursday, November 29, 2007

How to Run C# on Linux OS

Here i am going to explane how to run C#(not GUI based ) on linux OS step wise .
1) Installation Process
a) Go to the following web site
http://go-mono.com/sources-stable/
b) dowanload mono-1.2.5.2.tar.bz2
c) go on terminal (command prompt for windows user )
d) login to root user
e) move mono-1.2.5.2.tar.bz2 to /usr/local/src by using following code
mv mono-1.2.5.2.tar.bz /usr/local/src
f) also move to src directory
cd /usr/local/src
g) type the following command to untar ( ie unzip for windows user ) the package
tar -xjf mono-1.2.5.2.tar.bz2
a new directory is created named " mono-1.2.5.2 "
h) move to that directory and type
./configure (dot then back forward slash )
after the configeratin will finish type
make
after make is created type
make install
All these process take 30 to 35 minute so be clam and coll till the process ends .
After make is installed we are now redy to run and execute c# programe .
2) Runing and Executing the C# programe
I follow the same old method of learning a programin language ie by writing the same old our Hello word program .

a) open any text editor in linux (vim , vi etc )
vim hello.cs
here .cs is C# file extension
for writing on vim editor you have to change your mode from comman to insert . for this press " i ";
// Hello World in C Sharp
class Hello {
static void Main() {
System.Console.WriteLine("Hello World");
}
}
To exit from the vim editor with saving the file type ESC and then Type "wq" and press enter.
(ESC changes insert mode to command mode, wq stands for "write and quit " )
b) Here our first programe is written and saved . now we have to compile it and run it.
To compile it simply type on command prompt
mcs hello.cs
if there is no error then hello.exe is creted else it will return error message
To run this programe type on terminal
mono hello.cs
it will print " Hello World " on terminal

For more detail you can also reffer to this website
http://www.csharphelp.com/archives2/archive317.html