If you need to find the aspx page name (including the folder it's in, if applicable) use the AppRelativeCurrentExecutionFilePath property of the Http Request:
string filename=HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath;
This will return results like: ~/MyFolder/My.aspx or ~/MyRootLevel.aspx
I found this at: http://www.west-wind.com/weblog/posts/132081.aspx
Thursday, January 27, 2011
Thursday, January 13, 2011
Get Identity Value when Using Dynamic SQL
If you need to get an identity value when using dynamic sql use sp_executesql and an output parameter to accomplish this. You're identity value ends up in the @identity variable.
declare
@sqlstatement nvarchar(4000)
,@identity int
...
set @sqlstatement = '
insert into lp.' + @permittype +'PermitNumber
(dummy) values (''dummy'') select @identity = scope_identity()';
EXECUTE sp_executesql @sqlstatement, N'@identity INTEGER OUTPUT', @identity OUTPUT
This is a great article on dynamic sql and using variables:
http://www.kodyaz.com/articles/tsql-sp_executesql-with-output-parameters.aspx
and
http://www.sommarskog.se/dynamic_sql.html
declare
@sqlstatement nvarchar(4000)
,@identity int
...
set @sqlstatement = '
insert into lp.' + @permittype +'PermitNumber
(dummy) values (''dummy'') select @identity = scope_identity()';
EXECUTE sp_executesql @sqlstatement, N'@identity INTEGER OUTPUT', @identity OUTPUT
This is a great article on dynamic sql and using variables:
http://www.kodyaz.com/articles/tsql-sp_executesql-with-output-parameters.aspx
and
http://www.sommarskog.se/dynamic_sql.html
Wednesday, January 5, 2011
Change Cursor to an Hourglass for Web Applications
To accomplish this on the web you'll need to call a javascript or use CSS. This is a javascript example. In your aspx page add this code in the header or above your content:
wrap it in a script tag
function hourglass()
{
document.body.style.cursor = "wait";
}
In your aspx.cs code behind add this C# code in your Page Load (obviously change the button name to match yours)
btnSubmit.Attributes.Add("onclick", "javascript: hourglass();");
In my example the page redirects to another page, so the cursor set itself back automatically, but you may need to set it back to "default" yourself.
wrap it in a script tag
function hourglass()
{
document.body.style.cursor = "wait";
}
In your aspx.cs code behind add this C# code in your Page Load (obviously change the button name to match yours)
btnSubmit.Attributes.Add("onclick", "javascript: hourglass();");
In my example the page redirects to another page, so the cursor set itself back automatically, but you may need to set it back to "default" yourself.
Subscribe to:
Posts (Atom)