簡體   English   中英

ASP服務器端的Calll html按鈕onclick事件登錄身份驗證事件

[英]calll html button onclick event from asp server side login authenticate event

需要以編程方式從登錄事件中單擊html按鈕(代碼后面嗎?html按鈕使用以下方法將變量發送到Flash:無響應-無回發,並通過javascript使用ExternalInterface API。

從SWF> ASPX很棒,但是在使用登錄事件進行身份驗證之后,需要通過JavaScript從ASPX將User.Identity從ASPX發送到SWF,這是沒有時間上班的...(從Login按鈕調用HTML事件)嘗試了JavaScript腳本編寫登錄事件沒有運氣,可能是因為回發清除了SWF變量-所以也許保持獨立(登錄然后是html send)可以工作...

這是我的相關代碼:

 function sendToActionScript(value) {
   swfobject.getObjectById("Property").sendToActionScript(value);   
 }

  </script>

 <object ..// SWF File embedded> </object

 <form id="form1" runat="server">
 <asp:Login id="login1" OnAuthenticate="login1_Authenticate"/>
 </form>

 <form id="form" onsubmit="return false;">
 <input type="text" name="input" id="input" value="" runat="server" />
 <button id="btnInput"
        runat="server"
        causesvalidation="false"
        visible="true"
        style="width: 51px"
        onclick="sendToActionScript(this.form.input.value);"  >Send</button><br />
 </form>  


 // CODE BEHIND 

 protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
 {
   // do something to get User Id and Role
   //bind the string (user or role) to input.value
   //then call the HTML button onclick event to send it to SWF file.
   //which I could put in separate function and call from Login_Authenticate
 }

誰能幫我,我沒主意了。

克雷格

在您的身份驗證處理程序中,您需要在頁面上注入一些javascript,以簡單的sendToActionScript使用適當的值調用sendToActionScript函數。 我想您可以單擊該按鈕,但是當您可以直接調用該方法時,為什么要引入額外的開銷。

 this.ClientScript.RegisterStartupScript( this.GetType(), "sendtoactionscript",
        "<script type='text/javascript'>"
            + "sendToActionScript(this.form.input.value);"
            + "</script>" );

請注意,我已將其拆分為單獨的字符串,僅用於格式化目的。

OnClick是事件處理程序的服務器端聲明。 使用onClientClick或執行btnInput.Attributes.Add(“ onclick”,“ sendToActionScript(this.form.input.value);”);

我最終使用Swfobject flashvars

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM