Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

RegisterExpandoAttribute with ajax

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeremy - 12 Jul 2007 21:08 GMT
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?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.