Posts

Showing posts with the label Ajax

Donate

ScriptManager.RegisterStartupScript() Vs. ClientScript.RegisterStartupScript()

Hi! I have been struggling in manipulating scripts to focus to a particular control when a user executes a button or events triggered by postbacks.The scenario was in every button clicked, the focus will be transferred to another control. These butttons are inside an update panel and ajax tab container. The solution presented in an article i've previously posted was using ClientScript.RegisterStartupScript() to register a script. However, this script is registered in the Page object. But since my controls are inside an update panel which is partial postback rendering, the solution I've come up was using ScriptManager.RegisterStartupScript(). So, to register client scripts on an aspx page w/o ajax functionalities, use ClientScript: 1 ClientScript.RegisterStartupScript( this .GetType(), "MyScript" , script.ToString(), false ); And to register client scripts on an aspx page w/ ajax functionalities such as inside an update panel, use ScriptManager: 1 ScriptManager.

Register Client Scripts In ASP.NET Using ClientScriptManager Class

Source: ClientScriptManager Class C# Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 public void Page_Load (Object sender, EventArgs e) { // Define the name and type of the client scripts on the page. String csname1 = "PopupScript" ; String csname2 = "ButtonClickScript" ; // Get a ClientScriptManager reference from the Page class. System.Web.UI.ClientScriptManager cs = Page.ClientScript; // Check to see if the startup script is already registered. if (!cs.IsStartupScriptRegistered(csname1)) { String cstext1 = "alert('Testing');" ; cs.RegisterStartupScript(GetType(), csname1, cstext1, true ); } // Check to see if the client script is already registered. if (!cs.IsClientScriptBlockRegistered(csname2)) { StringBuilder cstext2 = new StringBuilder(); cstext2.Append( "" ); cs.RegisterClientScriptBlock(GetType(), csname2, cstext2.ToString(), false ); } } HTML Markup 1 2 3 4 5 6

(AJAX Tab Container Error)htmlfile: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus.

In my aspx page, I have an ajax tab container control, and inside each tab strip,i have server controls. During pageload,i want to set focus on a particular control but got this error during page load: htmlfile: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus. the solution is in this page: Setting focus to a textbox when in a tab panel errors

Donate