简体   繁体   中英

Pass Value from aspx javascript to ascx page

I have an user control and aspx login page. Now i validate login page and send return message to ascx page.i dont know whether it's possible or not. Please help me.

<%@ Register Src="~/usercontrol/WUC_MessageBoxes.ascx" TagName="MessageBox" TagPrefix="UC" %>

<script type="text/javascript">
        function ValidateLogin() {
            try {
                var user = document.getElementById('login')
                var pass = document.getElementById('password')
                var msg = document.getElementById('<%=mydatatopass.ClientID%>').innerHTML;
                msg = "haioasdfasdfasdf";
                if (user.textContent != '') {
                    if (pass.textContent != '') {
                      //Pass Error Message to User Control

                    } else {                          //Pass Error Message to User Control }

                } else {
                }
            }
            catch (ex) {

                alert(ex.message)
            }
        }
    </script> 

Post your form to the controller using Ajax

function () {
        $.ajax("/YourController/YourMethod", {
            data: ko.toJSON({ your data goes here }),
            type: "post", contentType: "application/json",
            success: function (result) {
                if (result.success) {
                    //what happens on success
                }
                else {
                    alert(result.success)
                }
            },

        });
    };

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