RegisterExpandoAttribute with ajax

J

Jeremy

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?
 
B

bruce barker

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top