我在javascript中使用了一種方法,並在c#中使用了一種方法,現在只需單擊一個按鈕,我想將它們都稱爲它們。只需點擊一次即可撥打javascript和c#方法
首先,我想調用名爲'Find_Direction'
的c#方法,因爲它得到輸入onclick,然後我將調用名爲calcRoute
的javascript方法後調用。
我是想這一點,但沒有任何的運氣:
<asp:Button id="Button1" UseSubmitBehavior="False" value="GetDirections" onclick="calcRoute" OnClientClick="Find_Direction" runat="server"/>
以下錯誤彈出:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1061: 'ASP.findroute_aspx' does not contain a definition for 'calcRoute' and no extension method 'calcRoute' accepting a first argument of type 'ASP.findroute_aspx' could be found (are you missing a using directive or an assembly reference?)
這種方式會首先執行find_direction方法嗎? @Sachin – 2013-03-03 09:11:34
不,我認爲你想在calcRoute之後執行find_Direction。但是,如果您希望find_Direction首先執行,而不是在像OnClientClick =「return Find_Direction」這樣的客戶端上點擊它,那麼沒有問題。 – Sachin 2013-03-03 09:53:14
我仍然在努力。因爲它似乎不是在javscript方法中。 @Sachin – 2013-03-03 10:33:39