Earlier today I was debugging a rather tricky issue. It came down to the fact that an ImageButton control was not getting its ImageUrl property set in certain scenarios. This would cause ASP.NET to output the following HTML for this control:
<input type="image" name="myName" id="myID" src="" />
This was causing the page to request Default.aspx since a src was not explicitly defined*. So be sure to set the ImageButton control (or its container element) to Visible="false" if you are not setting its ImageURL property. Otherwise you may have some code-behind logic on Default.aspx executed when you aren't expecting it!
* I assume this is because Default.aspx is set as the default document in IIS.
My initial thought is always to look for a property on the Page object, but this is actually a property on the ScriptManager. So if you want to only execute code if it isn't a partial page post back you can do the following:
// Do stuff here
When creating an advanced search you often need to dynamically create the Where statments in your SQL. Here is an easy way to do this in LINQ. In the example below orderID, lastName, firstName, shipped are all values retrieved from controls on the page.
var query = from orders in dataContext.MyOrdersTable
query = query.Where(order => order.OrderID == orderID);
query = query.Where(order => order.LastName == lastName);
query = query.Where(order => order.FirstName == firstName);
query = query.Where(order => order.Shipped == shipped);
myGridView.DataSouce = query;