Results 1 to 9 of 9

Thread: Is there a way to ensure that WebForm_FireDefaultButton function is available?

  1. #1

    Thread Starter
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Is there a way to ensure that WebForm_FireDefaultButton function is available?

    I want to programmatically force asp.net to include the WebForm_FireDefaultButton javascript.
    I'm looking something similar to the ClientScript.GetPostBackEventReference method, which ensures the __doPostBack javascript on the form.

    Actually I have a custom control that renders as a <div>.

    Now I want to add a DefaultButton property to it, just like a normal Panel control has.
    When we set the "DefaultButton" property of a Panel control, it automatically includes the javascript for "WebForm_FireDefaultButton", along with a call to that function:
    html Code:
    1. <div id="MyDiv"  onkeypress="javascript:return WebForm_FireDefaultButton(event, 'MyButton')">

    When I do the same thing in my custom control, it errors out with the message saying that WebForm_FireDefaultButton is not defined (which is obvious at present, because I don't know how to tell asp.net engine include it).

    So how do I make sure that it includes the javascript for "WebForm_FireDefaultButton" ?

    I don't want to hard-code the script in my control. I want it to include whatever way other asp.net controls like (Form, Panel etc.) do it.

    Anyone has any ideas about this?
    Last edited by Pradeep1210; Nov 26th, 2012 at 01:32 PM. Reason: described the problem in detail for someone who doesn't want to go thru the entire thread.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Is there a way to ensure that WebForm_FireDefaultButton function is available?

    You mean you want to embed the script?
    something like Page.RegisterStartupScript ?
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3

    Thread Starter
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Is there a way to ensure that WebForm_FireDefaultButton function is available?

    Yes, I want it to include the script for WebForm_FireDefaultButton.

  4. #4
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Is there a way to ensure that WebForm_FireDefaultButton function is available?

    Hi.Then i think what i mentioned, or registerclientscriptblock will do the trick.
    Let us know.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  5. #5

    Thread Starter
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Is there a way to ensure that WebForm_FireDefaultButton function is available?

    No, you didn't get the point.

    When we set a default button for any panel or form, then asp.net automatically includes a javascript function "WebForm_FireDefaultButton".

    I need some programmatic way to include this script without actually setting any default button.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  6. #6
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Is there a way to ensure that WebForm_FireDefaultButton function is available?

    Ah, ok.Well i can't say i've ever tried that.Can you explain what is your goal here?Maybe we can find a more suitable solution.
    If you need to include a firedefault without actually have a default button, what is the use?
    If however you want to define the default programmatically on multiple forms, then I show this one:
    http://www.abstraction.net/content/a...ng%20enter.htm
    For panels:
    http://kpumuk.info/asp-net/using-pan...ol-in-asp-net/
    Maybe it can help?
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  7. #7

    Thread Starter
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Is there a way to ensure that WebForm_FireDefaultButton function is available?

    Actually I have a custom control that renders as a <div>.

    Now I want to add a DefaultButton property to it, just like a normal Panel control has.
    When we set the "DefaultButton" property of a Panel control, it automatically includes the javascript for "WebForm_FireDefaultButton", along with a call to that function:
    html Code:
    1. <div id="MyDiv"  onkeypress="javascript:return WebForm_FireDefaultButton(event, MyButton)">

    When I do the same thing in my custom control, it errors out with the message saying that WebForm_FireDefaultButton is not defined (which is obvious at present, because I don't know how to include it).

    So how do I make sure that it includes the javascript for "WebForm_FireDefaultButton" ?

    I don't want to hard-code the script in my control. I want it to include whatever way other asp.net controls like (Form, Panel etc.) do it.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  8. #8
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Is there a way to ensure that WebForm_FireDefaultButton function is available?

    Can't say i have tried something like this.
    I can only suggest hard coding the WebForm_FireDefaultButton script.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  9. #9
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: Is there a way to ensure that WebForm_FireDefaultButton function is available?

    I haven't included a webresource in a custom controll so googled and found this article. http://weblogs.asp.net/dwahlin/archi...avascript.aspx

    That's using custom script in a webresource but you could refrence the resource for defaultButton.... which is...?

    BTW pannels are rendered as div's in the browser so another option could be using a pannel with defaultbutton on it instead of your div.
    The problem with computers is their nature is pure logic. Just once I'd like my computer to do something deluded.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width