Javascript Question

J

Joey

I have a third party menu server control. I want to be able to plant
"__doPostBack('MyControlName',' ')" into the NavigateURL property of it
to force a postback when it is clicked. On the server side I have made
a code block named "protected void MyControlName_Click()" But when I
run the page and click on the menu item, the server side code block
does not execute. The page already has the necessary javascript
functions to do the postbacks as I have linkbuttons and other controls
on the page. I can see that I am not wiring this up properly. How
should I do it?
 
B

bruce barker \(sqlwork.com\)

you need to subclass the third party control and implement the postback
event handling interface. something like:

public class MyControl : ThirdPartControl,IPostBackEventHandler
{
public delegate void MyEventHandler(object sender, EventArgs e);
public event MyEventHandler Click;

protected virtual void OnClick(EventArgs e)
{
if (Click != null) Click(this, e);
}
public void RaisePostBackEvent(string eventArgument)
{
// ignore data
OnClick(new PostBackerEventArgs(new EventArgs());
}
protected override void OnInit(EventArgs e)
{
// tell .net to enable client postbacks
Page.GetPostBackEventReference(this);
}
}

then register you serverside callback.

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top