Gaiala
asked on
set Focus on a programmatically created GridView
Hello,
how can I set a focus on a programmatically created gridview?
for example in gridview3 line 7?
how can I set a focus on a programmatically created gridview?
for example in gridview3 line 7?
yes. you have focus() method for every control which you can use it.
if you use 1.1 framework , you can create your own method and use it.
Focus myFocus = new Focus();
myFocus.SetFocus(this.Butt on1,this);
1 public class Focus
2 {
3
4 public void SetFocus(Control controlToFocus, Page webPageInstance)
5 {
6
7
8 StringBuilder scriptFunction = new StringBuilder();
9
10 string scriptClientId;
11 scriptClientId = controlToFocus.ClientID;
12
13 scriptFunction.Append(
14
15 "<script language='javascript'>");
16 scriptFunction.Append(
17
18 "document.getElementById(' ");
19 scriptFunction.Append(scri ptClientId );
20
21 scriptFunction.Append(
22
23 "').focus();");
24 scriptFunction.Append(
25
26 "</script>");
27 webPageInstance.ClientScri pt.Registe rStartupSc ript(GetTy pe(),"SetF ocusScript ",scriptFu nction.ToS tring()
28
29 );
30
31 }
32
33 }
refer here
http://forums.asp.net/t/987325.aspx
if you use 1.1 framework , you can create your own method and use it.
Focus myFocus = new Focus();
myFocus.SetFocus(this.Butt
1 public class Focus
2 {
3
4 public void SetFocus(Control controlToFocus, Page webPageInstance)
5 {
6
7
8 StringBuilder scriptFunction = new StringBuilder();
9
10 string scriptClientId;
11 scriptClientId = controlToFocus.ClientID;
12
13 scriptFunction.Append(
14
15 "<script language='javascript'>");
16 scriptFunction.Append(
17
18 "document.getElementById('
19 scriptFunction.Append(scri
20
21 scriptFunction.Append(
22
23 "').focus();");
24 scriptFunction.Append(
25
26 "</script>");
27 webPageInstance.ClientScri
28
29 );
30
31 }
32
33 }
refer here
http://forums.asp.net/t/987325.aspx
ASKER
yes I mean
Set focus to the control as in calling the Focus() method
The fact that it's programatically created doesn't seem relevant to me.
ok but how can I get the Gridview I want to set the Focus?
Set focus to the control as in calling the Focus() method
The fact that it's programatically created doesn't seem relevant to me.
ok but how can I get the Gridview I want to set the Focus?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
what do you mean by "set focus"? Set focus to the control as in calling the Focus() method, or select a row, as in setting the SelectedIndex property (seeing as how you want line 7)?
The fact that it's programatically created doesn't seem relevant to me.