2011-12-24 39 views
-2

後面我試圖從代碼隱藏調用js函數像Asp.net中的代碼調用JS

<if(result == true) 
    MyJsFunction(); 

我怎麼能做到這一點?

我試着像

string rowTestHide = @" <script type='text/javascript'>function showSuccessMessage(){ 
           showNotification({ 
            type : 'success', 
            message: 'This is a sample success notification' 
           });  
          }         
         </script>"; 
ClientScript.RegisterStartupScript(null,"rowTest", rowTestHide); 

,但它不工作

+0

請解釋_how_它不工作,可能還有相關的'showNotification'代碼。 – 2011-12-24 23:38:28

回答

1

你不想要的功能......你只是想運行它的時候了。像這樣:

string rowTestHide = @"<script type='text/javascript'> 
           showNotification({ 
            type : 'success', 
            message: 'This is a sample success notification' 
           });  
         </script>"; 
ClientScript.RegisterStartupScript(this.GetType(),"rowTest", rowTestHide); 
+0

它不起作用:( – 2011-12-24 21:41:45

+0

然後會發生什麼? – Hogan 2011-12-24 21:58:52

+0

什麼也沒有發生 – 2011-12-24 22:03:52