10:00 AM

FAQ .NET

Posted by pradeep T

How to prevent a Button from validating its form?
Set the CauseValidation property of the button control to false.


How can you change a Master Page dynamically at runtime?
To change a master page, set the MasterPageFile property of the @Page directive to point to the .master page during the PreInit page event.

What is a proxy of the server object in ASP.Net Remoting?
It is a fake copy of the server object that resides on the client side and behaves as if it was the server. It handles the communication between real server object and the client object. This process is also known as marshaling.

What is DataReader Object in ADO.Net?
It provides a forward-only, read-only, connected recordset.

It is most efficient to use when data need not to be updated, and requires forward only traverse. In other words, it is the fastest method to read data.

Example:

Filling dropdownlistbox.
Comparing username and password in database.
SqlDataReader rdr = cmd.ExecuteReader();

//Reading data

while (rdr.Read())
{

//Display data

string contact = (string)rdr["ContactName"];
string company = (string)rdr["CompanyName"];
string city = (string)rdr["City"];

}

What are the components of .NET DataProvider?

Posted by: Abhisek
The .NET DataProvider is a set of components that includes the Connection, Command, DataReader and DataAdapter objects. It is used for connecting to a database , executing commands and retrieving results. Using the .NET data provider we can either access database directly or use the disconnected approach. For the disconnected approach we use DataSet class.

Connection Object:- It is used to connect to the data source. Data source can be any database file. The connection object contains information like the provider name, server name, datasource name, user name and password.

Command Object:- It is used for connect the connection object to a DataReader or DataAdapter object. The command object allow us to execute SQL statement or a stored procedure in a data source.

DataReader Object:- It is used to read the data in a fast and efficient manner from the database. It is generally used to extract one or a few records or specific field values or to execute simple SQL statement.

DataAdapter Object:- It is used to fill data from the database into the DataSet object. it is use din the disconnected approach

Give Expansions of ODBC,OLE,OLE DB,ADO?

Posted by: Vpramodg
1.ODBC-Open Database Connectivity.
2.OLE-Object Linking and Embedding.
3.OLE DB-Object Linking and Embedding for Database.
4.ADO-ActiveX Data Object.

Components of data providers in ADO.NET?

Posted by: Tripati_tutu
Connection Object: The Connection object represents the connection to the database. The Connection object has ConnectionString which contains all the information required to connect to the database.

Command Object: The command object is used to execute stored procedures and command on the database. It contains methods such as ExecuteNonQuery, ExecuteScalar and ExecuteReader.

ExecuteNonQuery: It executes a command that doesn’t return any record, such as INSERT, UPDATE and DELETE.

ExecuteScalar: It executes and returns a single value from a database.

ExecuteReader: It returns a result set by the DataReader object.

DataReader Object: It provides a connected, forward-only and read-only recordset from a database. The Command.ExecuteReader method creates and returns a DataReader object. Since it is connected to the database through out its lifetime, it requires the use of connection object.

DataAdapter Object: This object acts like a communication bridge between the database and a dataset. It fills the dataset with data from the database. The dataset stores the data in the memory and it allows changes. The DataAdapter update method can transmit the changes to the database.

In connected data access you can connect through the DataReader objects of data provider. This object requires exclusive use of the connection object. It can provide fast and forward-only data access. It doesn't allow editing.

Disconnected data access is achieved through the DataAdapter object. This object establishes connection, executes the command, load data in the DataSet. The Dataset works independent of database. It contains data in the memory and can edit the data. The changes in the data can be transmitted to the database using Update method of DataAdapter object.

What are the types of authentication in ASP.Net?
ASP.Net provides infrastructure for authentication and authorization that will meet most of your needs for securing an .Net application. Four schemes are available in ASP.Net:
1. Forms-based authentication
2. Windows-based authentication
3. Microsoft Passport authentication
4. None - authentication disabled

Authentication is the process of identifying and verifying who the client accessing the server is.
For example, if you use

Windows authentication and are browsing an ASP.NET page from server -- ASP.NET/IIS would automatically use NTLM to authenticate you as SYNCFUSION\user1 (for example).
Forms based authentication, then you would use an html based forms page to enter username/password -- which would then check a database and authenticate you against the username/password in the database.

Authorization is the process of determining whether an authenticated user has access to run a particular page within an ASP.NET web application. Specifically, as an application author decide to grant or deny the authenticated user "SYNCFUSION\user1" access to the admin.aspx page. This could be done either by explictly granting/denying rights based on the username -- or use role based mappings to map authenticated users into roles (for example: an administrator might map "SYNCFUSION\user1" into the "Power Users" role) and then grant/deny access based on role names (allowing a degree of abstraction to separate out your authorization pol


ASP.Net Interview Questions and Answers


What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState?
ViewState is the mechanism used by the ASP.Net to keep track of server control state values that do not otherwise post back as part of the HTTP form. ViewState Maintains the UI State of a web page.
ViewState is base64-encoded. It is not encrypted but it can be encrypted by setting EnableViewStatMAC="true" & setting the machineKey validation type to 3DES. If you want to not to maintain the ViewState, include the directive <%@ Page EnableViewState="false" %> at the top of an .aspx page or add the attribute EnableViewState="false" to any control.

What is Cross Page Posting? How is it done?
By default, ASP.Net submits a form to the same page. In cross-page posting, the form is submitted to a different page. This is done by setting the PostBackUrl property of the button(that causes postback) to the desired page. In the code-behind of the page to which the form has been posted, use the FindControl method of the PreviousPage property to reference the data of the control in the first page.


What is a satellite assembly?
When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.


How to set a cookie?
HttpCookie myCookie = new HttpCookie("myWebSiteName");
myCookie.Value = "http://www.faqpanel.com/";
myCookie.Expires = DateTime.Now.AddMonths(6);
Response.Cookies.Add(myWebSiteName);

What is connection pooling in ASP.Net?
Connection pooling increases the performance of Web applications by reusing active database connections instead of creating a new connection with every request. Connection pool manager maintains a pool of open database connections. When a new connection requests come in, the pool manager checks if the pool contains any unused connections and returns one if available. If all connections currently in the pool are busy and the maximum pool size has not been reached, the new connection is created and added to the pool. When the pool reaches its maximum size all new connection requests are being queued up until a connection in the pool becomes available or the connection attempt times out.

How can you change a Master Page dynamically at runtime?
To change a master page, set the MasterPageFile property of the @Page directive to point to the .master page during the PreInit page event.


SESSION
http://www.codeproject.com/Articles/32545/Exploring-Session-in-ASP-Net

What does an assembly contain?
A ASP.Net assembly may contain the following elements:
1. Assembly Manifest - Metadata that describes the assembly and its contents
2. Source Code - Compiled into Microsoft intermediate language
3. Type Metadata - Defines all types, their properties and methods, and most importantly, public types exported from this assembly
4. Resources - Icons, images, text strings and other resources

What is the smallest unit of execution in ASP.Net?
An Assembly.
What is a formatter in ASP.Net Remoting?
A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing and decoding messages into data on the other end.

DELEGATES:

* Event is Arraylist of delegates .
* Delegate ( as its English meaning ) : Secretary or someone who connect two persons throuh him .
* Delegate can fire only one method
But Event fire more than one delegate , each call one method

* Example : in Windows App. or ASP.NET App.
Button : is a class that has internally an event called ( eg. click ) and there is
a method you want to do if this button clicked so make an instance of the delegate
which button.click deal with ( System.EventHandler ) and make this delegate
execute the method eg. Button1_Click

Code :
in initializer of The Form Class :
Button1.Click += new System.EventHandler(this.button1_Click) ;
And make amethod :
private void button1_Click(object sender, System.EventArgs e)
{
// write your own code
}


n brief, you can think of an event as being a bit like a property - but instead of having get/set operations, it has add/remove. The value being added/removed is always a delegate reference.

Delegates themselves support operations of:

Combine (chain multiple delegate instances together)
Remove (split them up again)
Invoke (synchronous or asynchronous)
Various things to do with finding out the target, invocation list etc
Note that delegates themselves are immutable, so combine/remove operations return a new delegate instance rather than modifying the existing ones.

Basically, a delegate is just a wrapper around what would be a function pointer in C (or a list of function pointers).

An event is an even higher level abstraction that wraps the concept of a delegate together with methods to subscribe and unsubscribe a method to such delegates.

An event is a “property” that exposes an add and remove method (invoked via += and -= in code) to add/remove subscribers to a delegate list.

9:55 AM

mechine.config Vs Web.config

Posted by pradeep T

When you modify the settings in the Web.Config file, you do not need to restart the Web service for the modifications to take effect.. By default, the Web.Config file applies to all the pages in the current directory and its subdirectories.


You can use the tag to lock configuration settings in the Web.Config file so that they cannot be overridden by a Web.Config file located below it. You can use the allowOverride attribute to lock configuration settings. This attribute is especially valuable if you are hosting untrusted applications on your server.

There are number of important settings that can be stored in the configuration file. Here are some of the most frequently used configurations, stored conveniently inside Web.config file..

1. Database connections.

2. Session States

3. Error Handling (CustomError Page Settings.)

4. Security (Authentication modes)

The Machine.Config file, which specifies the settings that are global to a particular machine. This file is located at the following path:



\WINNT\Microsoft.NET\Framework\[Framework Version]\CONFIG\machine.config



As web.config file is used to configure one asp .net web application, same way Machine.config file is used to configure the application according to a particular machine. That is, configuration done in machine.config file is affected on any application that runs on a particular machine. Usually, this file is not altered and only web.config is used which configuring applications.

9:53 AM

Page Life Cycle

Posted by pradeep T

An important article on the different methods and order they are executed during the load of an .aspx web page. ASP.NET.
In this article, we are going to discuss the different methods and order they are executed during the load of an .aspx web page.

When a visitor first requests an .aspx page on your server, the server sends it to the HTTP Pipeline. The HTTP Pipeline handles all processes involved in converting all of the application code into HTML to be interpreted by the browser. The first class initiated is called HttpRuntime. This class finds a free HttpApplication object to start processing the request. The HttpApplication object then runs the appropriate handler assigned in the web.config and machine.config files for the requested extension.

The extension .aspx can be handled by the HandlerClass or HandlerFactory class. The HttpApplication objects starts the IHttpHandler interface which begins processing the application code by calling the processRequest() method.

Need help with Windows Dedicated Hosting? Try Server Intellect. I'm a happy customer!

The processRequest() method then calls the FrameworkInitialize() method which begins building the control trees for the requested page. Now the processRequest() method cycles through the page's life cycle in the order listed below.

Methods Description
Page_Init Page Initialization
LoadViewState View State Loading
LoadPostData Postback Data Processing
Page_Load Page Loading
RaisePostDataChangedEvent PostBack Change Notification
RaisePostBackEvent PostBack Event Handling
Page_PreRender Page Pre Rendering Phase
SaveViewState View State Saving
Page_Render Page Rendering
Page_Unload Page Unloading
The first processed method is Page_Init(). Once the control tree has been created, the controls declared in the .aspx file are initialized. The controls can modify some of the settings set in this method to be used later in the page life cycle. Obviously no other information is available to be modified at this time.

The next processed method is LoadViewState(). The Viewstate contains stored information that is set by the page and controls of the page. This is carried to and from every aspx page request per visitor.

I just signed up at Server Intellect and couldn't be more pleased with my Windows Server! Check it out and see for yourself.

The next processed method is LoadPostData(). These are values associated with the HTML form elements the visitor has typed, changed or selected. Now the control has access to this information which can update their stored information pulled from the Viewstate.

The next processed method is Page_Load(). This method should look familiar and is usually the most common used method on the server side application code for an .aspx file. All code inside of this method is executed once at the beginning of the page.

The next processed method is RaisePostDataChangedEvent(). When a visitor completes a form and presses the submit button, an event is triggered. This change in state signals the page to do something.

The next processed method is RaisePostBackEvent(). This method allows the page to know what event has been triggered and which method to call. If the visitor clicks Button1, then Button1_Click is usually called to perform its function.

Server Intellect offers Windows Hosting Dedicated Servers at affordable prices. I'm very pleased!

The next processed method is Page_PreRender(). This method is the last chance for the Viewstate to be changed based on the PostBackEvent before the page is rendered.

The next processed method is SaveViewState(). This method saves the updated Viewstate to be processed on the next page. The final Viewstate is encoded to the _viewstate hidden field on the page during the page render.

The next processed method is Page_Render(). This method renders all of the application code to be outputted on the page. This action is done with the HtmlWriter object. Each control uses the render method and caches the HTML prior to outputting.

The last processed method is Page_Unload(). During this method, data can be released to free up resources on the server for other processes. Once this method is completed, the HTML is sent to the browser for client side processing.

Now you should have a little bit better understanding of the order of methods executed in the request of an .aspx file.

courtesy :http://www.dotnettutorials.com/tutorials/performance/page-life-cycle-asp.aspx

4:37 PM

Origin of Logs

Posted by pradeep T

Links
http://logbase2.blogspot.com/2007/12/log-base-2.html


History of Logarithms
Logarithms were invented independently by John Napier, a Scotsman, and by Joost Burgi, a Swiss. Napier's logarithms were published in 1614; Burgi's logarithms were published in 1620. The objective of both men was to simplify mathematical calculations. This approach originally arose out of a desire to simplify multiplication and division to the level of addition and subtraction. Of course, in this era of the cheap hand calculator, this is not necessary anymore but it still serves as a useful way to introduce logarithms. Napier's approach was algebraic and Burgi's approach was geometric. The invention of the common system of logarithms is due to the combined effort of Napier and Henry Biggs in 1624. Natural logarithms first arose as more or less accidental variations of Napier's original logarithms. Their real significance was not recognized until later. The earliest natural logarithms occur in 1618.
It can’t be said too often: a logarithm is nothing more than an exponent. The basic concept of logarithms can be expressed as a shortcut........ Multiplication is a shortcut for Addition: 3 x 5 means 5 + 5 + 5
Exponents are a shortcut for Multiplication: 4^3 means 4 x 4 x 4
Logarithms are a shortcut for Exponents: 10^2 = 100.
The present definition of the logarithm is the exponent or power to which a stated
number, called the base, is raised to yield a specific number.
The logarithm of 100 to the base 10 is 2. This is written: log10 (100) = 2.
Before pocket calculators — only three decades ago, but in “student years” that’s the age of dinosaurs — the answer was simple. You needed logs to compute most powers and roots with fair accuracy; even multiplying and dividing most numbers were easier with logs. Every decent algebra books had pages and pages of log tables at the back.
The invention of logs in the early 1600s fueled the scientific revolution. Back then scientists, astronomers especially, used to spend huge amounts of time crunching numbers on paper. By cutting the time they spent doing arithmetic, logarithms effectively gave them a longer productive life. The slide rule, once almost a cartoon trademark of a scientist, was nothing more than a device built for doing various computations quickly, using logarithms. See Eli Maor’s e: The Story of a Number for more on this.
Today, logs are no longer used in routine number crunching. But there are still good reasons for studying them. Why do we use logarithms, anyway?
• To find the number of payments on a loan or the time to reach an investment goal
• To model many natural processes, particularly in living systems. We perceive loudness
of sound as the logarithm of the actual sound intensity, and dB (decibels) are a logarithmic scale. We also perceive brightness of light as the logarithm of the actual light energy, and star magnitudes are measured on a logarithmic scale.
• To measure the pH or acidity of a chemical solution. The pH is the negative logarithm of the concentration of free hydrogen ions.
• To measure earthquake intensity on the Richter scale.
• To analyze exponential processes. Because the log function is the inverse of the
exponential function, we often analyze an exponential curve by means of logarithms. Plotting a set of measured points on “log-log” or “semi-log” paper can reveal such relationships easily. Applications include cooling of a dead body, growth of bacteria, and decay of a radioactive isotopes. The spread of an epidemic in a population often follows a modified logarithmic curve called a “logistic”.
• To solve some forms of area problems in calculus.
(The area under the curve 1/x, between x=1 and x=A, equals ln A.)

1:54 PM

Algos Problems

Posted by pradeep T

Prime number computation
topological sorting - library of machine parts- each part should be placed in the order of useage
dynamic programming - DNA Matching - (A,B,C,D,F) .. (B,C,D) close match
convex hull or convex envelope
discrete Fourier transforms

1:16 PM

Links for DS

Posted by pradeep T

http://cgm.cs.mcgill.ca/~godfried/teaching/algorithms-web.html
http://sbge.tripod.com/DSIndex.html
http://www.cs.berkeley.edu/~jrs/61b/lec/07
http://www.cs.auckland.ac.nz/~jmor159/PLDS210/ds_ToC.html

Finite automata
Computation Theory
Complexity Theory

1:12 PM

Smart pointers

Posted by pradeep T

To be smarter than regular pointers, smart pointers need to do things that regular pointers don't. What could these things be? Probably the most common bugs in C++ (and C) are related to pointers and memory management: dangling pointers, memory leaks, allocation failures and other joys. Having a smart pointer take care of these things can save a lot of aspirin...

The simplest example of a smart pointer is auto_ptr, which is included in the standard C++ library. You can find it in the header , or take a look at Scott Meyers' auto_ptr implementation. Here is part of auto_ptr's implementation, to illustrate what it does:

template class auto_ptr
{
T* ptr;
public:
explicit auto_ptr(T* p = 0) : ptr(p) {}
~auto_ptr() {delete ptr;}
T& operator*() {return *ptr;}
T* operator->() {return ptr;}
// ...
};
As you can see, auto_ptr is a simple wrapper around a regular pointer. It forwards all meaningful operations to this pointer (dereferencing and indirection). Its smartness in the destructor: the destructor takes care of deleting the pointer.

9:39 PM

UIActivity Indicator

Posted by pradeep T

- (void) createProgressionAlertWithMessage:(NSString *)message withActivity:(BOOL)activity
{
progressAlert = [[UIAlertView alloc] initWithTitle: message
message: @"Please wait..."
delegate: self
cancelButtonTitle: nil
otherButtonTitles: nil];

// Create the progress bar and add it to the alert
if (activity) {
activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activityView.frame = CGRectMake(139.0f-18.0f, 80.0f, 37.0f, 37.0f);
[progressAlert addSubview:activityView];
[activityView startAnimating];
} else {
progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(30.0f, 80.0f, 225.0f, 90.0f)];
[progressAlert addSubview:progressView];
[progressView setProgressViewStyle: UIProgressViewStyleBar];
}
[progressAlert show];
[progressAlert release];
}

9:38 PM

UIElements Complete Tutorials

Posted by pradeep T

UITextField

Code:
UITextField *username =[[UITextField alloc] initWithFrame:CGRectMake(24.5, 65, 270, 30)];
username.delegate=self;
username.textAlignment=UITextAlignmentCenter;
username.borderStyle=UITextBorderStyleRoundedRect;
username.placeholder=@"Username\n";
username.autocorrectionType=UITextAutocorrectionTypeNo;
username.autocapitalizationType=UITextAutocapitalizationTypeNone;
[self.view addSubview:username];
UIActionSheet
Code:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"This is where the information will go"
delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil
otherButtonTitles:@"Email", @"Tech Support",@"Website",@"Cancel", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
actionSheet.destructiveButtonIndex = 3; // make the second button red (destructive)
[actionSheet showInView:self.view];
[actionSheet release];
Selecting a button on UIActionSheet
Code:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0){
// do stuff
}
}

UISwitch
Code:
UISwitch *switchIt = [[UISwitch alloc] initWithFrame:CGRectZero];
switchIt.on=NO;
[self.contentView addSubview:switchIt];
UILabel
Code:
UILabel *usernameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
usernameLabel.text=@"Personal Location Checkin";
usernameLabel.adjustsFontSizeToFitWidth=YES;
[self.contentView addSubview:usernameLabel];
UISearchBar
Code:
UISearchBar *mySearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 45)];
mySearchBar.delegate = self;
mySearchBar.showsCancelButton = YES;
mySearchBar.barStyle=UIBarStyleBlackOpaque;
mySearchBar.placeholder=@"Enter Name or Phone Number";
mySearchBar.keyboardType=UIKeyboardTypeNamePhonePad;


[self.view addSubview: mySearchBar];
UIView
Code:
UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
contentView.backgroundColor = [UIColor grayColor];
self.view = contentView;
[contentView release];
UITableView
Code:
UITableView *myBeaconsTableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 45, self.view.bounds.size.width, 375)];
myBeaconsTableView.delegate=self;
myBeaconsTableView.dataSource=self;

[self.view addSubview:myBeaconsTableView];
Or to make a grouped table view (like in preferences)

Code:
UITableView *settingsTableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 40, self.view.bounds.size.width, 375) style:UITableViewStyleGrouped];
settingsTableView.delegate=self;
settingsTableView.dataSource=self;
[self.view addSubview:settingsTableView];
UINavigationBar
Plain no Title
Code:
myNavBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 45)];
[self.view addSubview:myNavBar];
Black Opaque (no title)
Code:
myNavBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 45)];
myNavBar.barStyle=UIBarStyleBlackOpaque;
[self.view addSubview:myNavBar];
Black Translucent (no title)
Code:
myNavBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 45)];
myNavBar.barStyle=UIBarStyleBlackTranslucent;
[self.view addSubview:myNavBar];
To add title and other buttons

Code:
UINavigationItem *navItem = [[UINavigationItem alloc] initWithTitle:@"Around Me"];
[myNavBar pushNavigationItem: navItem];
To add buttons with image
Code:
refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(action:)];
[navItem setLeftBarButtonItem:refreshButton];
Add button with Text
Code:
refreshButton = [[UIBarButtonItem alloc] initWithTitle:@"About Us" style:UIBarButtonItemStyleBordered target:self action:@selector(action:)];
[navItem setRightBarButtonItem:refreshButton];
How to add comments
Code:
When you want to add a comment about a line of code you do this

// Comment

To do a multi-lined comment you would do this

/* This
is
multi-lined
comment
*/
UIWebView
Code:
dailyWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0, 45, self.view.bounds.size.width, 375)];
dailyWebView.delegate=self;
dailyWebView.scalesPageToFit=YES;
[dailyWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]];
[self.view addSubview:dailyWebView];
UITextView
Code:
UITextView *textView = [[[UITextView alloc] initWithFrame:frame] autorelease];
textView.textColor = [UIColor blackColor];
textView.font = [UIFont fontWithName:@"Helvetica" size:15];
textView.delegate = self;
textView.backgroundColor = [UIColor whiteColor];

textView.text = @"TEXT TO GO IN HERE";
[self.view addSubView:textView];

UISegmentedControl
Code:
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:
[NSArray arrayWithObjects:
[UIImage imageNamed:@"segment_check.png"],
[UIImage imageNamed:@"segment_search.png"],
[UIImage imageNamed:@"segment_tools.png"],
nil]];
frame = CGRectMake( 0,
0,
self.view.bounds.size.width,
35);
segmentedControl.frame = frame;
[segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
segmentedControl.segmentedControlStyle = UISegmentedControlStylePlain;
segmentedControl.selectedSegmentIndex = 1;
[self.view addSubview:segmentedControl];
UIAlertView
Code:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"UIAlertView" message:@"Your message"
delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Button1", @"Button2", nil];
[alert show];
[alert release];
This is just some UI elements that can be added through code

11:04 AM

Device Orientation && UILABLE ROTATE

Posted by pradeep T

I have got my own custom UIViewController, which contains a UIScrollView with an UIImageView as it's subview. I would like to make the image to auto rotate when device orientation changes, but it doesn't seem to be working...

In the header file, I've got;

@interface MyViewController : UIViewController {
IBOutlet UIScrollView *containerView;
UIImageView *imageView;
}
These components are initialised in the loadView function as below;

containerView = [[UIScrollView alloc] initWithFrame:frame];

NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://..."]];
UIImage *image = [[UIImage alloc] initWithData:data];
imageView = [[UIImageView alloc] initWithImage:image];
[image release];

[containerView addSubview:imageView];
And I have added the following method, assuming that's all I need to make the view auto-rotate...

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
MyViewController loads fine with the image I've specified to grab from the URL, and the shouldAutorotate... function is being called, with the correct UIInterfaceOrientation, when I flip the device too.

However, didRotateFromInterfaceOrientation method do not get called, and the image doesn't seem to rotate itself... Could someone please point out what I need to add, or what I have done wrong here?


UILABLE ROTATE :

/*************************
As August said, I'm not sure of your use case on this, but there's a reasonably straightforward way to do it using Core Animation. First, you'll need to add the QuartzCore framework to your project and do a

#import
somewhere in your headers.

Then, you can apply a rotational transform to your UILabel's underlying layer using the following:

yourLabel.layer.transform = CATransform3DMakeRotation(M_PI, 0.0f, 1.0f, 0.0f);
which will rotate the label's CALayer by 180 degrees (pi radians) about the Y axis, producing the mirror effect you're looking for.

11:00 AM

UITAbleView -Row invisible in keypad

Posted by pradeep T

1


I faced the same situation. It is suggested that you change the height of your view when the keyboard appears. The problem in the case you've described is, there is not enough content in the tableview to scroll up and still have something in the area hidden by the keyboard.

If you adjust the size of the tableview to be equal to 480-150 (height of view - height of keyboard), and use scrollToRowAtIndexPath, it will work as expected. Once the keyboard hides again, change back the height of the tableview to the original height.

10:50 AM

UIView Flip Transition !!

Posted by pradeep T

These are the UIView parameters that can be animated:
frame
bounds
center
transform
alpha


[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:kTransitionDuration];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];

[self.view addSubview:newView];
[self.view setAlpha:0.0];
[UIView commitAnimations];


/**************************************

-(IBAction)swap:(id)sender{
//If you need to position anything and not have it animated add it before the beginAnimations block

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.6]; //The time in seconds the animation should last.

// In Interface Builder I set the tag of the first button to 1 and the second to 2.
// You could create seperate functions for both bottoms but in this case it's not needed.

if ([sender tag] == 1){
[view1 removeFromSuperview];
[window addSubview:view2];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window cache:YES];
}
else{
[view2 removeFromSuperview];
[window addSubview:view1];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache:YES];
}

[UIView commitAnimations];
}


/****************************************

2


I think the only thing you're looking for is:

UIView's

+ (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache;
and

UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
These animation transitions can only be used within an animation block. The transition is set on the container view and then the old view is swapped out for the new view, then the animation is committed.

Like:

CGContextRef context = UIGraphicsGetCurrentContext();

[UIView beginAnimations:nil context:context];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:yourContainerView cache:YES];
[yourContainerView exchangeSubviewsAtIndex:0 withSubviewAtIndex:1];
[UIView commitAnimations];


- (void)loadFlipsideViewController {

FlipsideViewController *viewController = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
self.flipsideViewController = viewController;
[viewController release];

// Set up the navigation bar
UINavigationBar *aNavigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)];
aNavigationBar.barStyle = UIBarStyleBlackOpaque;
self.flipsideNavigationBar = aNavigationBar;
[aNavigationBar release];

UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(toggleView)];
UINavigationItem *navigationItem = [[UINavigationItem alloc] initWithTitle:@"Test123"];
navigationItem.rightBarButtonItem = buttonItem;
[flipsideNavigationBar pushNavigationItem:navigationItem animated:NO];
[navigationItem release];
[buttonItem release];
}


- (IBAction)toggleView {
/*
This method is called when the info or Done button is pressed.
It flips the displayed view from the main view to the flipside view and vice-versa.
*/
if (flipsideViewController == nil) {
[self loadFlipsideViewController];
}

UIView *mainView = mainViewController.view;
UIView *flipsideView = flipsideViewController.view;

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:([mainView superview] ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft) forView:self.view cache:YES];

if ([mainView superview] != nil) {
[flipsideViewController viewWillAppear:YES];
[mainViewController viewWillDisappear:YES];
[mainView removeFromSuperview];
[infoButton removeFromSuperview];
[self.view addSubview:flipsideView];
[self.view insertSubview:flipsideNavigationBar aboveSubview:flipsideView];
[mainViewController viewDidDisappear:YES];
[flipsideViewController viewDidAppear:YES];

} else {
[mainViewController viewWillAppear:YES];
[flipsideViewController viewWillDisappear:YES];
[flipsideView removeFromSuperview];
[flipsideNavigationBar removeFromSuperview];
[self.view addSubview:mainView];
[self.view insertSubview:infoButton aboveSubview:mainViewController.view];
[flipsideViewController viewDidDisappear:YES];
[mainViewController viewDidAppear:YES];
}
[UIView commitAnimations];
}

/*************************************************
// Start Animation Block
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:[self superview] cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];

//int nextView = currentView + 1;
// Animations
[[self superview] exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
//And so I would do: [[self superview exchangeSubviewAtIndex:currentView withSubviewAtIndex:nextView];
//Doesn't work because curentView is not global... with each instance of a class it's reset to what it's instanciated to.
//currentView++;

// Commit Animation Block
[UIView commitAnimations];

10:20 AM

Code Signing !! deployment of iapps

Posted by pradeep T

CodeSign error: a valid provisioning profile is required for product type ‘Application’ in SDK ‘Device - iPhone OS 2.2″
This error will appear when you update your provisioning profile in iPhone SDK 2.2
or after the expiration of developer certificate and that you have a new provisioning profile from the developer portal
This is the solution (which is modified from http://www.furmanek.net/54/iphone-sdk-22-codesign-error/)
Suppose you have copied your provisioning profile called “iPhone_Development.mobileprovision” to the Library folder and build & go an old iPhone project called “MyApp”, and this annoying error appears
(1) cd ~/Library/MobileDevice/Provisioning\ Profiles/
(2) find out the UUID of the provisioning profile
strings iPhone_Development.mobileprovision | grep ".*-.*"
output is like this
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
(3) copy that UUID between the string tag
(4) close xcode and go to your project
cd ~/Projects/MyApp/MyApp.xcodeproj
(5) Use a text editor to open the project.pbxproj
find the string PROVISIONING_PROFILE
paste the UUID that you copied from step (3) and put it in both Debug and Release Sections (do multiple finds) for the following line
e.g.
PROVISIONING_PROFILE = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
(6) Launch XCode and open the project and build & go again




This seems to be a chronic issue and is unresolved across many forums. This error occurs when you Build and Go for Device - iPhone OS 2.1 and can be verified when looking under Project Info > Build > Code Signing > Code Signing Provisioning Profile > Any iPhone Device, the name of your Provisioning Profile (ie. ITP DAP Projects) will not be listed as a Value.
I was able to resolve this issue by restoring my iPhone in Xcode under the Summary tab of the Organizer window.
Before doing so, you should of course confirm you have the Development Certificate and WWDR Intermediate Certificate in place, and have the Provisioning Profile both on your Mac under Library > MobileDevice > Provisioning Profile and on your iPhone under Settings > General > Profile

10:17 AM

UseFull Links !!

Posted by pradeep T

Blogs :
http://iappdevs.com/
http://www.iphonedevforums.com/
http://www.iphonesdkarticles.com/2008/11/parsing-xml-files.html
http://www.idevgames.com/forum/showthread.php?t=16500
http://forums.macrumors.com/showthread.php?t=629384
http://discussions.apple.com/message.jspa?messageID=7520321
http://stackoverflow.com/questions/121615/how-to-tint-a-uibutton
http://www.iphonedevsdk.com/forum/
http://www.fifthfloormedia.com/iphone-tutorial-animation-demo-1/

Mac :
http://hci.rwth-aachen.de/cocoaheads
http://stefan.hafeneger.name/2008/06/03/iphone-datamatrix-reader/
http://iphone.trac.wordpress.org/browser

coreGraphics !! buton gradient

http://cocoawithlove.com/2008/09/drawing-gloss-gradients-in-coregraphics.html

article on XML PARSING:

http://www.iphonesdkarticles.com/2008/11/parsing-xml-files.html



Codes:
http://blog.coriolis.ch/2008/11/09/add-an-uiprogressview-or-uiactivityindicatorview-to-your-uialertview/
http://www.ipodtouchfans.com/forums/showthread.php?t=102782

Sample Codes:
http://code.google.com/p/cookbooksamples/downloads/list



Topic Wise:

10:06 AM

NSArray and Sorting

Posted by pradeep T

Array declaration !!

NSArray *theSimpsons = [[NSArray arrayWithObjects:
@"Homer Jay Simpson", @"Marjorie "Marge" Simpson",
@"Bartholomew "Bart" J. Simpson", @"Lisa Marie Simpson",
@"Margaret "Maggie" Simpson",
@"Abraham J. Simpson",
@"Santa's Little Helper",
@"Ned Flanders", @"Apu Nahasapeemapetilon",
@"Clancy Wiggum", @"Charles Montgomery Burns",nil] retain];


NSArray *myarray=[NSArray arrayWithObjects:@"32", @"54",@"1", nil];
NSArray *sortedArray= [myarray sortedArrayUsingFunction:intSort context:NULL];
NSLog(@"%@",sortedArray);
}

NSInteger intSort(id num1, id num2,void *context)
{
int v1=[num1 intValue];
int v2=[num2 intValue];
if(v1<v2)
return NSOrderedAscending;
else if (v1>v2)
return NSOrderedDescending;
else
return NSOrderedSame;
}

10:01 AM

UIPickerView !!

Posted by pradeep T

#import

@interface StartUpViewController : UIViewController {
UIPickerView *accuracyPicker;
NSArray *pickerItems;
}
@property(nonatomic,retain)UIPickerView *accuracyPicker;
@end

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
pickerItems = [[NSArray alloc] initWithObjects:@"Best",@"10 \t KMS",@"20 \t KMS",@"30 \t KMS",@"40 \t KMS",nil];

}
return self;
}



// returns the number of columns to display.
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}

// returns the number of rows
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return [pickerItems count];
}

#pragma mark ---- UIPickerViewDelegate delegate methods ----

// returns the title of each row
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
NSString *currentItem = [pickerItems objectAtIndex:row];
return currentItem ;
}

// gets called when the user settles on a row
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{

NSString *currentItem = [pickerItems objectAtIndex:row];
printf("\n Accuracy set :%s",[currentItem UTF8String]);
}


- (void)viewDidLoad {
[super viewDidLoad];
UIView *mview = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
//[[UIScreen mainScreen] applicationFrame] this fits the view frame to complete secreen
accuracyPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 75, 100, 100)];
//creating the picker view
accuracyPicker.autoresizingMask = UIViewAutoresizingFlexibleWidth;
accuracyPicker.delegate = self;
accuracyPicker.dataSource = self;
accuracyPicker.showsSelectionIndicator=YES;//for showing the picker
mview.backgroundColor=[UIColor darkGrayColor];//for the background color
[mview addSubview:accuracyPicker];

self.title =@"Welcome to Hotels App";
self.view = mview;
[mview release];

}

9:58 AM

UITableView -iphone

Posted by pradeep T

this is an article about table view!!

MAKING table view GROUPED ::

tb = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStyleGrouped];

************

UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,320,440) style:UITableViewStyleGrouped];
tableView.rowHeight = 55;
[tableView setSectionHeaderHeight:5];
[tableView setSectionFooterHeight:5];

2. Setting with Delegate methods.
_______________________________________________________
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 25.0f;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 25.0f;
}
Setting with properties
___________________________________________________________
UITableView *theTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 440) style:UITableViewStyleGrouped];
theTableView.delegate = self;
theTableView.dataSource = self;
theTableView.backgroundColor=[UIColor brownColor];
UIImageView *img=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"flag_green(2).png"]];
img.frame=CGRectMake(5, 10, 5, 5);
[theTableView setTableHeaderView:img]

2. Setting with Delegate methods.
_______________________________________________________
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section // custom view for header. will be adjusted to default or specified header height
{
UIImageView *img=[[UIImageView alloc]initWithImage:myimageview];
img.frame=CGRectMake(5, 10, 10, 10);
return img;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section // custom view for footer. will be adjusted to default or specified footer height
{
UIImageView *img=[[UIImageView alloc]initWithImage:myimageview];
img.frame=CGRectMake(5, 10, 10, 10);
return img;
}

9:51 AM

UIView !!

Posted by pradeep T

This blog contains details about UIView !!


- (void)applicationDidFinishLaunching: (UIApplication *)application {

UIButton *myButton= [[UIButton alloc] init];
myButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
myButton.frame = CGRectMake(105,180, 115, 35);
[myButton setTitle:@"Apply Image" forState:UIControlStateNormal];
myButton.backgroundColor = [UIColor clearColor];
[myButton addTarget:self action:@selector(ApplyImage: ) forControlEvents:UIControlEventTouchUpInside];

[window addSubview:myButton];//So Here we keeping a button on windowthe button action is ApplyImage() methos calling
[window makeKeyAndVisible];
[myButton release];
}

-(void)ApplyImage:(id)sender
{
UIView *mview= [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];

UIImageView *img=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"fantasy_13.jpg"]];
img.frame=CGRectMake(0, 0, img.frame.size.width, img.frame.size.height);
[mview addSubview:img];
[img release];

UILabel *name = [[UILabel alloc]initWithFrame:CGRectMake(105,180,250,25)];
name.text = @"This is my View Example";
name.textColor=[UIColor whiteColor];
name.font=[UIFont boldSystemFontOfSize:13];
name.backgroundColor=[UIColor clearColor];
[mview addSubview:name];
[name release];

[window addSubview:mview];
[mview release];
}

9:43 AM

UIbutton !! complete details

Posted by pradeep T

Hi everyone !! this is a new thread  I am starting ...... its a blog which contains iphone coding !! I have created this as a reference for myself in my development work and also help people who are new to iphone !! 



UIButton *myButton= [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
myButton.frame = CGRectMake(105,180, 115, 35);
[myButton setTitle:@"Apply Image" forState:UIControlStateNormal];
myButton.backgroundColor = [UIColor clearColor];
[myButton addTarget:self action:@selector(ApplyImage: ) forControlEvents:UIControlEventTouchUpInside];
 

9:11 PM

The WEAKER SEX !!!

Posted by pradeep T


I read an article recently in the paper ... its a wonderful article which speaks on how males are loosing their hold of dominance in the world.... the author talks about the presence of anima -(feminine aspect present within the male ) and animus ( masculine aspect within a female).... he explain s how the male within the female is evolving and making the females strong as equal to male... at the same time males are getting weaker by yielding to the female (amino character ) and losing their hold in this world.............. guy & gals please read the following article .... to know WHO IS THE STRONGEST SEX....

A recently published book called Save the Males, written by leading American columnist Kathleen Parker, has caused a major furore in the United States owing to its central theme that it’s extremely hard to be a man in the 21st century, since men are being effectively emasculated by the expectations that feminism has thrust on them. That metrosexualisation of the modern man has only resulted in diminishing his capacity to provide for the woman and the family is the basic theme that Kathleen Parker expounds upon. Apparently, she does this with a lot of felicity, for, I have only read the reviews of the book and some of the responses to it, but I am looking forward to getting my hands on it, for, it promises to be a good read. One aspect of what the author says does resonate with my own understanding of the gender conflict. Despite conventional wisdom having it that the male of the species is the more empowered of the two genders, I believe that the human male is the more handicapped of the two genders and whatever “empowerment” he seems to enjoy today is more virtual than real. Permit me to explore this premise.

It would be fair to say that at no other time in recorded history than at the present has the human male been at the crossroads, as far as defining his identity is concerned. This is a rather unusual situation for him to be in, for, whatever else he has or has not been, he has been reasonably sure of what he was, where he was going and how he was going to get there. This was the situation even until the 1960s when male and female roles were very clearly delineated and men knew what precisely was expected of them. The hunter-gatherer role that was refined over the centuries to the role of the provider-protector is the one that man seems to have adapted to with the greatest degree of comfort. It seemed to be in keeping with his anatomical prowess and gave him the opportunity to express his identity by utilising his natural assets and strengths, thereby providing him a substrate on which he could define his essential masculinity. The better the provider, the better the man; the stronger the protector, the stronger the man.

A fairly straightforward equation that the women’s liberation movement unfortunately put paid to by questioning and actively encroaching on the domain of the larger environment that the male had defined his very maleness in. The threatened response of the male to this incursion could be interpreted to mean that he is unwilling to concede his social position of dominance to the female, since the provider-protector is the one who holds all the strings. However, we need to probe the issue further and go one level deeper to understand, acknowledge and address a more fundamental sub-text that is in operation.

Core of identity

At the core of the sense of one’s self is the recognition that one is created from two genders. Each individual will therefore necessarily be the repository of the generic attributes of both genders, even though biologically only one may predominate. It is not one’s maleness or femaleness alone that defines one’s identity, it is the harmony between the two that determines how comfortable and integrated one’s identity is going to be. Karl Gustav Jung, the celebrated Swiss psychoanalyst and one-time protégé of Sigmund Freud, used the term anima to refer to the feminine aspects of the man and the term animus to the masculine aspects of the woman. In other words, shocking as this may be to the more macho in our midst, inside every man there lies an unexpressed woman. And even more shocking is the proposition that the object of masculine identity development is not the elimination of this woman, but acknowledging the existence of and fine-tuning the feminine side with the masculine part of the identity. In other words, blending the yin and the yang. Unfortunately, men have either embraced their anima too much or not enough, as a result of which they have either over-metrosexualised themselves or ended up being committed retrosexuals. The “masculine woman” has become more socially acceptable than the “feminine man”, who is still an object of derision. And herein lies the root of the gender conflict. Women find it easy to pursue their masculinity; men find it disagreeable to even acknowledge, let alone pursue their femininity.

Steady inroads

When one looks back at social evolution over the latter half of the last century, it is readily apparent that women, once they decided on the direction they wanted to take, were able to make inroads into what were traditionally male bastions — territories men had protected and mystified over the centuries as being particularly unsuitable to the woman. Whatever the nature of work-related activity, women have shown the capacity not just to function as effectively as their male counterparts, but have often bested the latter in their chosen areas of strength. In the process, some women, in the aggressive pursuit of their animus have lost touch with their essential femininity. An unfortunate by-product really, since this is hardly conducive to the integrated development of the woman. What has been most striking about the women’s liberation movement is the ease with which women have made the domain shift. In other words, it appears that the task of being a provider-protector is not a particularly specialised one; you don’t have to be a man to do it. However, when it comes to femininity, the parity seems to vanish, since it is the woman alone who has the biological capacity to bear a child. She usually gets to choose whether to have a child, when to have a child and how many children she should have. The man’s cooperation is desirable though not mandatory, for, sperm banks can come to the rescue. Men are completely marginalised from this uniquely female experience, unless the women involves him to whatever extent she may choose. From the man’s point of view, it would appear that being feminine is a specialised activity. And this is why the male feels threatened by women’s liberation. Not because women are encroaching on his territory, but because he can never completely encroach on hers. She can do pretty much everything that he can, but the converse is not true. So, he responds twice as aggressively to her, often painting himself into a lonely corner in the process.

Critical equilibrium

The way out of the situation is to remember that even as the male pursues his feminine side, he does not have to lose his masculinity and become a woman. Nor for that matter does a woman need to lose her femininity as she explores her animus. For gender equilibrium to be maintained, it is harmony between the yin and the yang that is critical. When one approaches this issue with equanimity, it is perfectly possible to find a balance of power between the genders that pays due attention to the assets and liabilities of both. However when stridency and competitiveness predominate, the man is going to end up feeling disempowered and the genders are going to be stuck in an indefinite face-off, for neither wants to be the first to blink.