Javascript Question

Discussion in 'ASP .Net' started by Joey, May 1, 2006.

  1. Joey

    Joey Guest

    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?
     
    Joey, May 1, 2006
    #1
    1. Advertising

  2. 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)


    "Joey" <> wrote in message
    news:...
    >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?
    >
     
    bruce barker \(sqlwork.com\), May 1, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mcdeveloper
    Replies:
    1
    Views:
    4,209
    mcdeveloper
    Jun 13, 2006
  2. CRON
    Replies:
    24
    Views:
    200,850
    Adrienne Boswell
    Jun 20, 2006
  3. Mark Rae

    JavaScript or not JavaScript

    Mark Rae, Sep 5, 2006, in forum: ASP .Net
    Replies:
    36
    Views:
    1,101
    Paul Sture
    Sep 9, 2006
  4. Nathan Sokalski
    Replies:
    4
    Views:
    590
    PJ on Development
    Nov 8, 2007
  5. Jimolo
    Replies:
    2
    Views:
    213
    Gregor Kofler
    Jan 20, 2008
Loading...

Share This Page