PDA

View Full Version : [FIXED] [V0.5] RegisterClientOnReadyInitBlock causes error



Karel Frajták
Apr 25, 2008, 8:38 AM
Hello, I wanted to convert ASP.NET dropdownlist to ExtJS combo using JS code from ExtJS examples (http://extjs.com/deploy/dev/examples/form/combos.html) (I use hidden field, because I cannot pass DropDownList to RegisterClientOnReadyInitBlock method as 1st parameter). This code is in Page_Load method:

ScriptManager1.RegisterClientOnReadyInitBlock(Hidd enField1, "DropDownList1-OnReady",
@"var converted = new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
transform:'DropDown1',
width:135,
forceSelection:true });");

and following code is rendered

<script type="text/javascript">
//<![CDATA[
Ext.BLANK_IMAGE_URL='/WebSite1/cool/extjs/resources/images/default/s/gif/cool.axd';Ext.onReady(function(){Ext.QuickTips.ini t();var converted = new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
transform:'state',
width:135,
forceSelection:true
});
// furthercode ...
this.HiddenField1=new Ext.form.Hidden ({applyTo:"HiddenField1_TextBox",id:"HiddenField1"});});
</script>
<!-- Coolite ASP.NET Web Controls [Community Edition]. Version 0.4.1.42666. "Default" Theme. -->
<link rel="stylesheet" type="text/css" href="/WebSite1/cool/extjs/resources/css/ext-all-embedded/css/cool.axd" />
<script type="text/javascript" src="/WebSite1/cool/extjs/adapter/ext/ext-base/js/cool.axd"></script>
<script type="text/javascript" src="/WebSite1/cool/extjs/ext-all/js/cool.axd"></script>

which causes error, because Ext is referenced before script libraries are loaded. Without registration everything works fine. I tried to move ScriptManager tag up and down the page, but it didn't help.
When I paste the rendered HTML to static HTML page and swapped the script tags, it worked (i.e. both scripts cool.axd first and then Ext.onReady)
Thanks for your help.

Vladimir
Apr 25, 2008, 8:56 AM
Please use ScriptContainer in page header

(see post for help http://forums.ext.net/showthread.php?threadid=203-4-1.aspx)

Karel Frajták
Apr 25, 2008, 9:02 AM
That doesn't help (see attachment). I need to execute my script inside Ext.onReady function. It renders ok, but in wrong order.

geoffrey.mcgill
Apr 28, 2008, 5:21 PM
Hi Karel,


It's probably best to just place your script inline in the <head> after a ScriptContainer control.


Example



<head runat="server">
<ext:ScriptContainer ID="ScriptContainer1" runat="server" />
<script type="text/javascript">
Ext.onReady(function(){
var converted = new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
transform:'DropDown1',
width:135,
forceSelection:true
});
});
</script>
</head>


There's still some work to be done to the RegisterClientOnReadyInitBlock, although eventually you will be able to add to the OnReadyInitBlock from code-behind.


Hope this helps.

Karel Frajták
Apr 30, 2008, 4:50 AM
Thank you very much, that worked!