Using GET and __VIEWSTATE in ASP.Net Forms

October 23, 2007

In my previous post, I described the steps to set up a form to use the HTTP GET method.

I failed to mention that this method also works for forms embedded in a MasterPage.

I showed how to clear the hidden variables, such as __VIEWSTATE, with a line of Javascript code.

However, it turns out that the presence of the __VIEWSTATE parameter in the URL defines how ASP.Net treats the other URL parameters.

Read the rest of this entry »


Using GET in ASP.Net Forms

October 22, 2007

By default, ASP.Net Forms use the POST method to handle all callbacks to the form (button and linkbuttons clicks, control changes, etc.)

Query forms, however, usually, tend to use the GET method, following the logic: use GET for queries, use POST for changes.

Also, if you use GET, the search term will become part of the URL, which lets you bookmark a search result.

Read the rest of this entry »


Generate Excel sheets from your ASP.Net page

October 17, 2007

A web application that I develop allows the user to generate some statistics.

A FormView component contains all the selection criteria to generate the statistics, and a GridView displays the results provided by a stored procedure.

The next step was to allow the user to download this data into Excel.
Read the rest of this entry »


How much space do my SQL Server tables use?

October 11, 2007

The built-in stored procedure sp_spaceused generates a resultset containing the size of the database, or, when passed a table name, the size of a database table.

Using a cursor to iterate through all user tables, one can easily get a list of all tables and their sizes:

create table #t
(
  name nvarchar(128),
  rows varchar(50),
  reserved varchar(50),
  data varchar(50),
  index_size varchar(50),
  unused varchar(50)
)

declare @id nvarchar(128)
declare c cursor for
select name from sysobjects where xtype='U'

open c
fetch c into @id

while @@fetch_status = 0 begin

  insert into #t
  exec sp_spaceused @id

  fetch c into @id
end

close c
deallocate c

select * from #t
order by convert(int, substring(data, 1, len(data)-3)) desc

drop table #t

Follow

Get every new post delivered to your Inbox.