1) Make a field readonly:
txtName.Attributes.Add("readonly", "readonly")
2) Keyboard enter button is pressed in the textbox and fire an event:
This is done to ensure that when the keyboard enter button is pressed in the textbox we fire the "imgBtnSearch" click event
txtAccountNumber.Attributes.Add("onkeypress", "return WebForm_FireDefaultButton(event, '" + imgBtnSearch.ClientID + "')")
3) To set the focus on a control like Textbox when the page loads.
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "focus", "setTimeout(""try{ document.getElementById('" & txtApplicationNumber.ClientID & "').focus(); } catch(err){}"", 1200);", True)
4) To directly access the key and value of the resource file.
lblApplicationNumber.Text = GetGlobalResourceObject("xxx ", "ApplicationNumber") ////Where Main refers for a file "xxx.resx"
5) To disable controls of a form/page
For Each ctrl As Control In Me.Controls
Me.EcollManager.DisableControl(ctrl)
Next
// Below is the method definition
Public Sub DisableControl(ByVal ctrl As Control)
For Each subctrl As Control In ctrl.Controls
DisableControl(subctrl)
Next
If TypeOf ctrl Is TextBox Then
CType(ctrl, TextBox).Enabled = True
CType(ctrl, TextBox).ReadOnly = True
ElseIf TypeOf ctrl Is RadioButtonList Then
CType(ctrl, RadioButtonList).Enabled = False
ElseIf TypeOf ctrl Is CheckBox Then
CType(ctrl, CheckBox).Enabled = False
ElseIf TypeOf ctrl Is RadioButton Then
CType(ctrl, RadioButton).Enabled = False
End If
End Sub
Ashraf
No comments:
Post a Comment