We've developed various custom controls that use
Page.ClientScript.RegisterExpandoAttribute. This method creates a variable
at the bottom of the page and populates its properties.
My problem is that my control is in the edit template of a grid view. When
initially viewing the page, the control isn't created so
registerexpandoattribute doesn't fire. When I click edit the grid shows the
edit template, causing the control to get created and now
RegisterExpandoAttribute fires, but because it's in the update panel, the
javascript variable and it's properties won't get rendered. How should this
be handled in a control that could be used in an update panel?
bruce barker - 12 Jul 2007 23:06 GMT
try (air code):
public void RegisterExpando(Control ctl, string name, string value)
{
ScriptManager.RegisterClientScriptBlock(ctl,
typeof(Page),
"expando" + name,
string.Format(@"
$get('{0}').{1}='{2}';
", ctl.ClientID,name,JQuote(value)),
true);
}
// sample not complete
public string JQuote(string s)
{
s = s.Replace(@"\",@"\\");
s = s.Replace("'","\'");
s = s.Replace("\n",@"\n");
return s;
}
-- bruce (sqlwork.com)
> We've developed various custom controls that use
> Page.ClientScript.RegisterExpandoAttribute. This method creates a variable
[quoted text clipped - 7 lines]
> javascript variable and it's properties won't get rendered. How should this
> be handled in a control that could be used in an update panel?
Teemu Keiski - 13 Jul 2007 12:17 GMT
I think ScriptManager has also RegisterExpandoAttribute method. Doesn't that
work?
http://ajax.asp.net/docs/mref/M_System_Web_UI_ScriptManager_RegisterExpandoAttri
bute_5_fc08db2e.aspx
It should be compatible with partial page rendering.

Signature
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
> We've developed various custom controls that use
> Page.ClientScript.RegisterExpandoAttribute. This method creates a
[quoted text clipped - 7 lines]
> javascript variable and it's properties won't get rendered. How should
> this be handled in a control that could be used in an update panel?