Find the Row index when you click a button in a gridview by using the following in the button click method in code behind
GridViewRow row = ((LinkButton)sender).Parent.Parent as GridViewRow;
Response.Write(row.RowIndex);
Other way to use it is to have a command Name(for ex:View) and a Command Argument for the button and then using the GridView_RowCommand(object sender, GridViewCommandEventArgs e) _
There you can use some thing like
if (e.CommandName.ToString().Equals("View"))
{
int currentRowIndex = Int32.Parse(e.CommandArgument.ToString());
}
Monday, May 24, 2010
Thursday, May 20, 2010
VS 2005 takes too much time to load
VS 2005 takes too much time to load when you open it or trying to open a project.
Go to Tools -- > Import and Export Settings
and select Reset Settings.
That should do it.
You can do it as often as you want
Go to Tools -- > Import and Export Settings
and select Reset Settings.
That should do it.
You can do it as often as you want
Friday, April 9, 2010
Force the users to download rather than opening
For known content types like PDF, doc, mp3 etc..... when you have a download link it just opens it in the browser if the browser knows how to open..
If you want to force the user to download rather than being opened / played in web browser do the following with asp.net
Create a link using a link button and on button click do the following
string myFilename="../docs/abc.doc";
Response.AppendHeader( "content-disposition", "attachment; filename=" + myFilename );
The 2 lines above would force the browser to show the download box .
Hope this Helps.
Bobby
If you want to force the user to download rather than being opened / played in web browser do the following with asp.net
Create a link using a link button and on button click do the following
string myFilename="../docs/abc.doc";
Response.AppendHeader( "content-disposition", "attachment; filename=" + myFilename );
The 2 lines above would force the browser to show the download box .
Hope this Helps.
Bobby
Labels:
.NET,
ajax,
AppendHeader,
asp,
asp.net,
attachment,
Browser,
C#,
C#.NET,
Content Download,
content Type,
Content-disposition,
finename,
HTML,
Response,
Web apps
Wednesday, March 10, 2010
Keyboard quits working in visual studio 2005
For Some reason Unknown (Or known only to microsoft) some times the keyboard would quit working on VS 2005.
Re installation might help some times and some times it wont.
Looks like when you click on Design to switch to Design mode you will lose the Key board .
Here is a link for the Fix that i found which fixes it
http://petesbloggerama.blogspot.com/2006/07/internet-explorer-7-beta-3-and-loss-of.html
Thanks,
Bobby
Re installation might help some times and some times it wont.
Looks like when you click on Design to switch to Design mode you will lose the Key board .
Here is a link for the Fix that i found which fixes it
http://petesbloggerama.blogspot.com/2006/07/internet-explorer-7-beta-3-and-loss-of.html
Thanks,
Bobby
Labels:
asp,
asp.net,
C#,
C#.NET,
functionality,
key board doesnt work,
keyboard,
microsoft,
visual studio 2005,
vs 2005
Monday, February 22, 2010
Inject javascript in Head Section using asp.net
Even though it doesn't matter where the script is in the form or in the head section, you want to have it in the HEAD section of the HTML.
When you use Page.RegisterClientScriptBlock it injects the script in the body.
To inject in the HEAD section do the following...
When you use Page.RegisterClientScriptBlock it injects the script in the body.
To inject in the HEAD section do the following...
HtmlGenericControl myScriptCode = new HtmlGenericControl("script");
myScriptCode.Attributes.Add("type", "text/javascript");
myScriptCode.InnerHtml = "alert('Alert generated by Script in Head Section of HTML');";
this.Page.Header.Controls.Add(myScriptCode);
that should do it.check it by clicking view source and you should see the Script in HEAD section
If you want to refer to a js file as a external file use the SRC attribute
string jssrc="../abc.js";
HtmlGenericControl myScriptCode = new HtmlGenericControl("script");
myScriptCode.Attributes.Add("type", "text/javascript");
myScriptCode.Attributes.Add("src",jssrc);
this.Page.Header.Controls.Add(myScriptCode);
Labels:
.NET,
asp,
asp.net,
C#,
C#.NET,
dotnet,
FORM,
HEAD,
HTML,
inject,
javascript,
javascript from code behind,
javascript in head section,
programming,
SCRIPT,
software
Subscribe to:
Posts (Atom)