ssdf
File Upload in PHP with Example
{
echo "Return Code: " . $_FILES["file"]["error"] . "
"; }
else {
echo "Upload: " . $_FILES["file"]["name"] . "
";
echo "Type: " . $_FILES["file"]["type"] . "
";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "
";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
Mail in PHP with Example
Mail in PHP with Example
$to = someone@example.com;
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = someonelse@example.com;
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
Sesssion in PHP with example
if(isset($_SESSION['views']))
$_SESSION['views']=$_SESSION['views']+1;
else $_SESSION['views']=1;
echo "Views=". $_SESSION['views'];
Retrieve data from Cookie in PHP
echo $_COOKIE["user"];
// A way to view all cookies
print_r($_COOKIE);
Select Data From a Database Table with PHP Mysql
if (!$con)
{ die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$result = mysql_query("SELECT * FROM person");
while($row = mysql_fetch_array($result))
{
echo $row['FirstName'] . " " . $row['LastName'];
}
mysql_close($con);
Php Math Functions
abs()
Returns the absolute value of a number
acos()
Returns the arccosine of a number
acosh()
Returns the inverse hyperbolic cosine of a number
asin()
Returns the arcsine of a number
asinh()
Returns the inverse hyperbolic sine of a number
atan()
Returns the arctangent of a number as a numeric value between -PI/2 and PI/2 radians
atan2()
Returns the angle theta of an (x,y) point as a numeric value between -PI and PI radians
ceil()
Returns the value of a number rounded upwards to the nearest integer
cos()
Returns the cosine of a number
cosh()
Returns the hyperbolic cosine of a number
exp()
Returns the value of Ex
expm1()
Returns the value of Ex - 1
floor()
Returns the value of a number rounded downwards to the nearest integer
fmod()
Returns the remainder (modulo) of the division of the arguments
is_finite()
Returns true if a value is a finite number
is_infinite()
Returns true if a value is an infinite number
is_nan()
Returns true if a value is not a number
log()
Returns the natural logarithm (base E) of a number
log10()
Returns the base-10 logarithm of a number
max()
Returns the number with the highest value of two specified numbers
min()
Returns the number with the lowest value of two specified numbers
Free Download Wamp( Php mysql apache)
enjoy
http://www.wampserver.com/en/download.php
How to read the comma seperated values from a string asp.net C#?
string delimStr = " ,";
char[] delimiter = delimStr.ToCharArray();
foreach (string s in myString.Split(delimiter))
{
Response.Write (s.ToString ()+ "
");
}
How to get list of all files in the directory asp.net c#?
DataGrid1.DataSource = dirInfo.GetFiles("*.aspx");
DataGrid1.DataBind();
How to do text encryption and decryption Asp.net?
Encrypting Cookie Data with ASP.NET
Using MD5 to Encrypt Passwords in a Database
String Encryption With Visual Basic .NET
How to convert a string to HTML format asp.net C#?
Response.Write (HttpUtility.HtmlDecode (mystring));
How to get the IP address of the host accessing my site Asp.net C#?
How to format a Telphone number in the xxx-xxx-xxxx format Asp.net C#?
Response.Write(Telno.ToString("###-###-####"));
What is the difference between Server.Transfer and Server.Execute Asp.net C#?
Server.Execute is used to begin executing a new webform while still displaying the current web form. The contents of both forms are combined. This method works only when navigating to a webform page(.aspx)
How to change the Page Title dynamically Asp.net C#?
//Declare
protected System.Web.UI.HtmlControls.HtmlGenericControl Title1 ;
//In Page_Load
Title1.InnerText ="Page 1" ;
How to get the hostname or IP address of the server Asp.net C#?
HttpContext.Current.Server.MachineName
HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"]
How to convert string to a DateTime and compare it with another DateTime Asp.net C#?
Response.Write (blntimeIsOk);
How to validate that a string is a valid date Asp.net C#?
try
{
DateTime.Parse(MyString);
blnValid=true;
}
catch
{
blnValid=false;
}
How to include multiple vb/cs files in the source Asp.net?
<%@ assembly src="test1.vb" %>
<%@ assembly src="test2.vb" %>
or
<%@ assembly src="test1.cs" %>
<%@ assembly src="test2.cs" %>
How to convert milliseconds into time Asp.net?
Response.Write (ts.ToString () );
What is the difference between URL and URI?
A URI is just a unique string that uniquely identifies something, commonly a namespace. Sometimes they look like a URL that you could type into the address bar of your Web browser, but it doesn't have to point to any physical resource on the Web. It is just a unique set of characters, that, in fact, don't even have to be unique.
URI is the more generic term, and a URL is a particular type of URI in that a URL has to uniquely identify some resource on the Web.
What is the best way to output only time and not Date?
How to Compare time in Asp.net C#?
string t2 = DateTime.Now.ToString("t");
if (DateTime.Compare(DateTime.Parse (t1), DateTime.Parse (t2)) < 0 )
{
Response.Write(t1.ToString() + " is < than " + t2.ToString());
}
else
{
Response.Write(t1.ToString() + " is > than " + t2.ToString());
}
Is there a way to force garbage collection?
Is there any sample C# code for simple threading?
using System.Threading;
class ThreadTest
{
public void runme()
{
Console.WriteLine("Runme Called");
}
public static void Main(String[] args)
{
ThreadTest b = new ThreadTest();
Thread t = new Thread(new ThreadStart(b.runme));
t.Start();
}
}
what are the differences between Datalist DataGrid and datarepeater ?
DataGrid*Has a grid appearence by default*has a autoformat option*has default paging and sorting*has no separator between elements
DataRepeater
simple,read-only output, has no built in support for selecting or editing items, has no DEFAULT APPEARENCE,has no default paging.
what is the purpose of “base” keyword in c# ?
1) used to access a base class constructor
2) used to access a base class member in the derived class.
what is the difference between ref and out parameters ?
ref –> inout
out –> Out
Argument passed as ref must be initialized before it is passed to the method,where as incase of Out it’s not neccssary.but after a call to the method as an out parameter the variable must be initialized .out parameter can be used when you want to return more than one value from a method.
Describe the difference between inline and code behind - which is best in a loosely coupled solution?
Diffrence between Sever.transfer and respone.redirect
Response.Dedirect() :client know the physical loation (page name and query string as well). Context.Items loses the persisitance when nevigate to destination page
Explain the differences between Server-side and Client-side code?
Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc. Client side scripting is usually done in VBScript or JavaScript.
VBScript , JavaScript ???
VBScript is the client side scripting (script which is executed in your browser). This script looks like VB and it is only supported by Internet Explorer.JavaScript is also another client side scripting based on Java. This script is supported by Internet Explorer and also Netscape browser
what is difference between .dll & .exe?
ACTIVEX DLL:
An in-process component, or ActiveX DLL, runs in another application’s process.In-process components are used by applications or other in-process components. this allows you to wrap up common functionality (like an ActiveX Exe).
ACTIVEX EXE:
An out-of-process component, or ActiveX EXE, runs in its own address space. The client is usually an application running in another process.The code running in an ActiveX Exe is running in a separate process space. You would usually use this in N-Tier programming. An ActiveX EXE runs out of process while an ActiveX DLL runs in the same process space as VB app. Also, and ActiveX EXE can be run independent of your application if desired.
What is the difference between boxing and unboxing???
Describe garbage collection (in simple terms).
What is the transport protocol you use to call a Web service?
Whats an assembly?
What is the difference between a.Equals(b) and a == b?
a.Equals(b) is used to compare two objects
difference between thread and process?
process - executes single program
What does connection string consist of?
1.Data Source = “./SQLEXPRESS”; serverName\instanceName as Data Source to use a specific SQL Server instance
2.Initial Catalog = “DATABASE_NAME”;
Either3.Uid=”UserID for SQL server” ;4.Password= “Password for SQL server”;ORIntegrated Security=”True”; Use Windows security
5.Provider Name =”System.Data.SqlClient”;
What are the 2 types of polymorphism supports in .NET?
2. Polymorphism via Interfaces
What are interface in .NET?
What are indexes .NET?
What is isPostback property?
What diff b/w overloading and overriding? How can this be .net
Overloading : Derived classes may have different method signature with different parameters.
About a class access specifiers and method access specifiers
ASP.NET OBJECTS?
Explain the life cycle of an ASP .NET page.
1.PreInit, 2.Init, 3.InitComplete, 4.PreLoad, 5.Load, 6.Control events, 7.LoadComplete, 8.PreRender, 9. SaveStateComplete, 10. Render, 11.Unload
Differences between application and session
Describe the techniques for optimising your application?
. Avoid round-trips to server. Perform validation on client.
. Save viewstate only when necessary.
. Employ caching.
. Leave buffering on unless there is a dire need to disable it.
. Use connection pooling.
. Use stored procedures instead of in-line SQL or dynamic SQL.
What are the collection classes?
What are object-oriented concepts?
Object: An object is an instance of a class.
Encapsulation: hides detailed internal specification of an object, and publishes only its external interfaces. Thus, users of an object only need to adhere to these interfaces. By encapsulation, the internal data and methods of an object can be changed without changing the way of how to use the object.
Inheritance: A class that derives from another class - known as the base class - inherits the same methods and properties. This promotes reuse and maintainability.
Abstraction: the describing of objects by defining their unique and relevant characteristics (properties). Whilst an object may have 100s of properties normally only those properties of importance to the situation are described. (eg life policies premiums are normally important; whereas the time of day a policy was purchased is not usually of value).
Polymorphism: Allows objects to be represented in multiple forms. Even though classes are derived or inherited from the same parent class, each derived class will have its own behavior. (Overriding and hiding methods)
Explain the life cycle of an ASP .NET page.
Page Initialization Page_Init
View State Loading LoadViewState
Postback data processin LoadPostData
Page Loading Page_LoadPostBack Change Notification RaisePostDataChangedEvent
PostBack Event Handling Raise
PostBackEventPage
Pre Rendering Phase Page_PreRender
View State Saving SaveViewState
Page Rendering Page_RenderPage
Unloading Page_UnLoad
Asp.net Data Adapter
Dim objAdapter as New OleDbDataAdapter("SELECT * FROM users", objConn)
Dim ds as Dataset = New DataSet()objAdapter.Fill(ds, "users")
objAdapter.TableMappings.Add("adbtable", "users")With objAdapter.TableMappings(0).ColumnMappings .Add("PID", "ID") .Add("LastName", "LName") .Add("StreetAddress", "Addy")End WithobjAdapter.Fill(ds)
VS 2008 Overview
VS 2008 JavaScript Debugging
VS 2008 ASP.NET AJAX Control Extender Support
VS 2008 JavaScript Intellisense for Silverlight VS 2008 Web Designer and CSS Support
VS 2008 Nested Master Page Support
VS 2008 Vertical Split View Support
VS 2008 Support to Treat CSS and JavaScript Validation Issues as Warnings instead of Errors
Asp.net Sending Email with System.Net.Mail
message.From = new MailAddress("sender@foo.bar.com");
message.To.Add(new MailAddress("recipient1@foo.bar.com"));
message.To.Add(new MailAddress("recipient2@foo.bar.com"));
message.To.Add(new MailAddress("recipient3@foo.bar.com"));
message.CC.Add(new MailAddress("carboncopy@foo.bar.com"));
message.Subject = "This is my subject";
message.Body = "This is the content";
SmtpClient client = new SmtpClient();
client.Send(message);
ASP.NET 3.5 Extensions CTP Preview Released
This first ASP.NET 3.5 Extensions preview release includes:
ASP.NET AJAX Improvements: New ASP.NET AJAX features in the ASP.NET 3.5 Extensions release include better browser history support (back/forward button integration, and server-side history management support), improved AJAX content linking support with permalinks, and additional JavaScript library improvements.
ASP.NET MVC: This model view controller (MVC) framework for ASP.NET provides a structured model that enables a clear separation of concerns within web applications, and makes it easier to unit test your code and support a TDD workflow. It also helps provide more control over the URLs you publish in your applications, and more control over the HTML that is emitted from them.
ASP.NET Dynamic Data Support: The ASP.NET 3.5 Extensions release delivers new features that enable faster creation of data driven web sites. It provides a rich scaffolding framework, and will enable rapid data driven site development using both ASP.NET WebForms and ASP.NET MVC.
ASP.NET Silverlight Support: With the ASP.NET 3.5 Extensions release we'll deliver support for easily integrating Silverlight within your ASP.NET applications. Included will be new controls that make it easy to integrate Silverlight video/media and interactive content within your sites.
ADO.NET Data Services: In parallel with the ASP.NET Extensions release we will also be releasing the ADO.NET Entity Framework. This provides a modeling framework that enables developers to define a conceptual model of a database schema that closely aligns to a real world view of the information. We will also be shipping a new set of data services (codename "Astoria") that make it easy to expose REST based API endpoints from within your ASP.NET applications.
Why does URL mapping and rewriting matter?
1) Handling cases where you want to restructure the pages within your web application, and you want to ensure that people who have bookmarked old URLs don't break when you move pages around. Url-rewriting enables you to transparently forward requests to the new page location without breaking browsers.
2) Improving the search relevancy of pages on your site with search engines like Google, Yahoo and Live. Specifically, URL Rewriting can often make it easier to embed common keywords into the URLs of the pages on your sites, which can often increase the chance of someone clicking your link. Moving from using querystring arguments to instead use fully qualified URL's can also in some cases increase your priority in search engine results. Using techniques that force referring links to use the same case and URL entrypoint (for example: weblogs.asp.net/scottgu instead of weblogs.asp.net/scottgu/default.aspx) can also avoid diluting your pagerank across multiple URLs, and increase your search results.
Get data in database through SqlDataAdapter (C#)
String SQL = "SELECT ID, FirstName FROM Employee "
+ "WHERE ID IS NOT NULL";
SqlDataAdapter TitlesAdpt = new SqlDataAdapter SQL, ConnStr);
DataSet Titles = new DataSet();
// No need to open or close the connection
// since the SqlDataAdapter will do this automatically.
TitlesAdpt.Fill(Titles);
Matching Regular Expressions
End If
What is the best way to output only time and not Date?
Is it better to write code in C# or Visual Basic?
What is an interface and what is an abstract class?
Describe the difference between inline and code behind.
What is WSDL?
List the event handlers that can be included in Global.asax?
Session start and end event handlers
Per-request event handlers
Non-deterministic event handlers
Session state vs. View state
Large amounts of data - View state tends to increase the size of both the HTML page sent to the browser and the size of form posted back. Hence session state is used.
Secure data - Though the view state data is encoded and may be encrypted, it is better and secure if no sensitive data is sent to the client. Thus, session state is a more secure option.
Problems in serializing of objects into view state - View state is efficient for a small set of data. Other types like DataSet are slower and can generate a very large view state.
Differences Between XML and HTML?
HTML Defined set of tags designed for web display
XML Content driven
HTML Format driven
XML End tags required for well formed documents
HTML End tags not required
XML Quotes required around attributes values
HTML Quotes not required
XML Slash required in empty tags
HTML Slash not required
What is ViewState?
What is CLR, MSIL, CLS, CTS ??????????
It provides Services like
*Automatic Memory Management
*Thread Management
*Code Compilation & Execution
*Code Verification
*High level of security
*Structured Exception Handling
*Interoperability between Managed and Unmanaged code.
MSIL-MicroSoft INtermediate Language also called IL or CIL
It is a Language Independent
After Compiling the Source Code The CLR gives MSIL code
By using JIT compiler it converts into Native Code
CTS-Common Type System.It Provides the common data types to the compiler.
CLS-Common Language Specification.It has a set of rules to provide the Language Interaperability.And it is a subset of CTS
ImageMap in Asp.net
What's New in 2.0
Wizard Control - The wizard control allows you to easily add multi-step form entry scenarios to your pages.
Validation Groups - Validation groups allow multiple forms on a page to be separately validated.
Focus API - The Focus API enables you to set focus to any control on the page, specify default buttons to submit for input controls, and more.
Compilation Build Providers - ASP.NET 2.0 includes support for compiling declarative file formats when they are placed in the App_Code directory.
No Compile Pages - Pages in ASP.NET 2.0 can be excluded from the compilation process, to be interpreted at runtime instead.
Securing Non-ASP.NET content - Under IIS 6, you can easily secure non-ASP.NET files such as static images or classic ASP pages from within an ASP.NET application.
Client-Script Features - ASP.NET 2.0 includes several new features that take advantage of client-side script.
Diffrence Between Asp and Asp.net
ASP.NET provides increased performance by running compiled code.
ASP.NET code is not fully backward compatible with ASP.
New in ASP.NET
Better language support
Programmable controls
Event-driven programming
XML-based components
User authentication, with accounts and roles
Higher scalability
Increased performance - Compiled code
Easier configuration and deployment
Not fully ASP compatible

