简体   繁体   中英

Using OnClick and OnClientClick together doesn't work

I am using RadButton and RadWindow. On my RadButton I am trying to use OnClick and OnClientClick together to show a popup first and then go to a page via a server call.

 <div class="actionButtons">
                            <telerik:RadButton ID="btnMedLogin" CssClass="actionButton secondary" runat="server" Text="Doctor Login"
                                SingleClick="true" SingleClickText="Logging in" OnClick="btnDoctor_Click" OnClientClick="openwin();return false">
                            </telerik:RadButton>
                        </div>

When I just put

OnClick="btnDoctor_Click"

It works fine. however I want my radwindow modal to show as well so I put

OnClientClick="openwin();"

but it isn't working. I tried OnClientClicked but not working either.

Here is the rest of the code

   function openwin() {
            window.radopen(null, "RadWindow1");
        }

<telerik:RadWindowManager ID="RadWindowManager1" runat="server" Width="500px" Height="500px"> 
    <Windows> 
    <telerik:RadWindow ID="RadWindow1" runat="server" Modal="true" Behaviors="close" Title="Countdown Clock"> <ContentTemplate> 
    <div id="timerHorizontal">Some Text</div> 
    </ContentTemplate> </telerik:RadWindow> 
    </Windows>  </telerik:RadWindowManager>

How can I make it so it goes to the page and my radwindow pop up shows up?

Right name of the property is OnClientClicked , and it should be given a function name, so:

OnClientClicked="openwin"

This comes directly from docs :

Sets a name of a JavaScript function that will be called when the RadButton is > clicked, after the OnClientClicking event.

While the previous answer (to pass only the function name to the OnClientClicked property) is absolutely true, a subsequent postback will destroy your RadWindow. Thus, you will need to use AJAX for this RadButton so it does not dispose the RadWindow.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM