Setting a default button using Master Pages in ASP.NET

Posted by andy gaskell on May 2nd, 2006

This one’s pretty easy, but wasn’t apparent to me at first. Put this code in your Page_Load to set a default button in master pages:

this.Form.DefaultButton = this.YOUR_DEFAULT_BUTTON.UniqueID;

15 Responses

  1. chris Says:

    nice

  2. Marty Baker Says:

    Thanks, I was looking for that! I tried to use the plain ID of the button in my child page but that wasn’t working… Hmmm.. why? Anyways, it works now :)

  3. Alex Says:

    Thank You

  4. Terabanitoss Says:

    Hello
    You are The Best!!!
    Bye

  5. Jeb Says:

    I don’t know if you’re teh best, but you’re defiantly pickin’ up steam!

  6. Ivan Says:

    ur the man!

  7. Talha Says:

    thanks it worked in first go

  8. Ramandeep Says:

    Thanx a lot…simple n best..worked in first go.

  9. prasanth Says:

    Thank you

  10. Fatai Says:

    Thanks Very helpful.

  11. Joe Thompson Says:

    I was just working on my codes and found out this works for non-master pages as well.

  12. Will Says:

    Hey, this helped me out great. except i had to make a small change for it to fire off for me correctly

    Page.Form.DefaultButton = Me.you_button_here.UniqueID

    thanks for the help either way!

  13. Manish Buhecha Says:

    Hai, Thank you very much for your help…

  14. One doubt Says:

    if I have a master page with WebControl and the webcontrol has the button, my question is.. how assign default button in this case?

    thank

  15. dnyaneshwar Says:

    Thanks, it works fine.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.