简体   繁体   English

ASP服务器端的Calll html按钮onclick事件登录身份验证事件

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

Need to programmatically click an html button from a login event (code behind? the html button sends variables to Flash using method: no response - with no postback and uses ExternalInterface API via javascript. 需要以编程方式从登录事件中单击html按钮(代码后面吗?html按钮使用以下方法将变量发送到Flash:无响应-无回发,并通过javascript使用ExternalInterface API。

Going from SWF > ASPX is great, but need to send User.Identity to SWF from ASPX via javascript after authenticate with login event which am having impossible time getting to work... (calling HTML event from Login button) tried scripting in javascript to login event with no luck, possibly because postback clears SWF variables - so perhaps keeping separate (login then html send) would work... 从SWF> ASPX很棒,但是在使用登录事件进行身份验证之后,需要通过JavaScript从ASPX将User.Identity从ASPX发送到SWF,这是没有时间上班的...(从Login按钮调用HTML事件)尝试了JavaScript脚本编写登录事件没有运气,可能是因为回发清除了SWF变量-所以也许保持独立(登录然后是html send)可以工作...

Here is my relevant code: 这是我的相关代码:

 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
 }

Can anyone help me I am out of ideas. 谁能帮我,我没主意了。

Craig 克雷格

In your authenticate handler you need to inject some javascript onto the page that simply calls the sendToActionScript function with the appropriate value. 在您的身份验证处理程序中,您需要在页面上注入一些javascript,以简单的sendToActionScript使用适当的值调用sendToActionScript函数。 You could, I suppose, click the button, but why introduce the extra overhead when you can simply call the method directly. 我想您可以单击该按钮,但是当您可以直接调用该方法时,为什么要引入额外的开销。

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

Note that I've split it into separate strings just for formatting purposes. 请注意,我已将其拆分为单独的字符串,仅用于格式化目的。

OnClick is a server side declaration of the event handler. OnClick是事件处理程序的服务器端声明。 Use onClientClick or do btnInput.Attributes.Add("onclick", "sendToActionScript(this.form.input.value);"); 使用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