G
Guest
We can set the default button and focus field in ASP.Net 2.0 on the Form tag.
My form tag is in the Master page, but the controls are in containers.
I read through a few articles which did not work.
I added a "runat=server" to make the values visible to the devel. env.
I added properties to the masters codebehind:
Private strDefaultFocus As String
Private strDefaultButton As String
Public WriteOnly Property FormFocusControl() As String
Set(ByVal value As String)
strDefaultFocus = value
End Set
End Property
Public WriteOnly Property FormButtonControl() As String
Set(ByVal value As String)
strDefaultButton = value
End Set
End Property
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Me.frmMaster.DefaultButton = strDefaultButton
Me.frmMaster.DefaultFocus = strDefaultFocus
End Sub
In the Container, I set the default to a container control name:
CType(Master, Generic).FormButtonControl = "ibtnNext"
The button is of type asp:ImageButton.
When I run the page, I get "The DefaultButton of 'frmMaster' must be the ID
of a control of type IButtonControl."
I hope the resolution is as easy as placing the Generic assignment to a
different area. I have watched the Generic.Page_Load execute AFTER the
Container.Page_Load, so I assumed the controls were available.
Thank you
My form tag is in the Master page, but the controls are in containers.
I read through a few articles which did not work.
I added a "runat=server" to make the values visible to the devel. env.
I added properties to the masters codebehind:
Private strDefaultFocus As String
Private strDefaultButton As String
Public WriteOnly Property FormFocusControl() As String
Set(ByVal value As String)
strDefaultFocus = value
End Set
End Property
Public WriteOnly Property FormButtonControl() As String
Set(ByVal value As String)
strDefaultButton = value
End Set
End Property
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Me.frmMaster.DefaultButton = strDefaultButton
Me.frmMaster.DefaultFocus = strDefaultFocus
End Sub
In the Container, I set the default to a container control name:
CType(Master, Generic).FormButtonControl = "ibtnNext"
The button is of type asp:ImageButton.
When I run the page, I get "The DefaultButton of 'frmMaster' must be the ID
of a control of type IButtonControl."
I hope the resolution is as easy as placing the Generic assignment to a
different area. I have watched the Generic.Page_Load execute AFTER the
Container.Page_Load, so I assumed the controls were available.
Thank you