Posts Tagged ‘ Masterpage ASP.NET ’

Web Form Default Control Focus using Master Page

It’s straight-forward to set Default Focus with simple Web Form. Just set “defaultfocus” property to “ControlName” in “form” tag to get Default Control Focus in Web Form.


form id="form1" runat="server" defaultfocus="studentCodeTextBox"

However, it can not be done this way while using Master Page. Here, it has to be set at Page Load Event.


protected void Page_Load(object sender, EventArgs e)
{        
  Page.Form.DefaultFocus = userNameTextBox.ClientID;
}

Continue reading

Advertisements

Javascript with ASP.NET Master Page

I faced difficulties while using javascript in Web Form with Master Page. I was trying to use a Javascript Calender in asp.net page and this requires the FORM name and CONTROL name to initiate the calender. So, I started with the following code snippet.

                
new tcal ({
'formname': 'Form1',
'controlname': 'dateTextBox'				
});			 

Continue reading