I have a variable in a code behind control. I want to pass this value to an Ext.Net control in the web control. In my instance I have an ext.multicombo, and I want to pass a value to it’s Tooltip.
Code Behind:
protected override void OnPreRender(EventArgs e)
{
this.MaxFuelFilter = System.Configuration.ConfigurationManager.AppSettings["MyVariable"];
}
Control.aspx
<ext:multicombo ID="ddlFlightNumber" runat="server" ClientID="ddlFlightNumber" IndicatorTip="blah blah blah <%=MyVariable%> blah blah blah"></ext:multicombo>
How do I do something like this?
Thanks
There are a few issues:
The syntax you’re using will not work with ASP.NET Controls. This is an ASP.NET limitation, and not related to Ext.NET.
This is not valid ASP.NET syntax:
And, this is not valid ASP.NET syntax:
To pass a value into the property, you’ll need to use the
<%# %>DataBinding syntax.Although, this is also not valid ASP.NET syntax:
The property must ONLY contain the databind variable/script, example
AND… you must call .DataBind() on the Control, example
OR, with Ext.NET Controls, you can set the
.AutoDataBind="true"property and DataBinding will be automatically handled for you, exampleThe above custom property is auto-serialized into JavaScript and is now available to the client-side instance of that control (and others). You can then call that property from other JavaScript code.
For your scenario, I’d recommend tapping into an
<AfterRender>Listener of the<ext:MultiCombo>to get the property value and set something else. The following sample demonstrates the complete scenario (myVar), and also demonstrates another basic technique (myVar2) for passing a JavaScript variable into the client-side from the server-side.Example
You should be able to adapt the above to work with your custom Control.
Hope this helps.