如何从ASP.NET VB背后的代码做modalpopupextender [英] How to do modalpopupextender from code behind ASP.NET VB

查看:56
本文介绍了如何从ASP.NET VB背后的代码做modalpopupextender的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在尝试从VB后面的代码加载模式弹出扩展程序。我尝试过使用Javascript,但不确定我的语法是否正确。我尝试使用javascript在前面调用launchModal()函数,但它似乎没有调用该函数。理想情况下,该函数将搜索模态ID = mp1并加载它。但它不起作用。请帮助,谢谢。

Hi I am trying to load modal pop up extender from code behind VB. I have tried using Javascript but not sure if my syntax is correct. I tried using javascript to call launchModal() function in front but it doesn't seem to be calling the function. Ideally, The function will search for the modal ID = mp1 and load it. But it doesn't work. Please help, thank you.

<pre><div class="box-footer">
                        <asp:Button ID="btnSave" runat="server" Text="Save" onclick="btnSave_Click" class="btn btn-default" Width="100px" />
                        <asp:Button ID="Client" runat="server" Text="Client Side" class="btn btn-default" />
                    </div>
                    <!-- /.box-footer -->
                </div>
            </div>
            <!-- /.box -->
            <!-- general form elements disabled -->
        </div>
    </div>
    <!-- ModalPopupExtender -->
    <cc1:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panel1" TargetControlID="Client"
        CancelControlID="btnClose" BackgroundCssClass="modal-background">
    </cc1:ModalPopupExtender>
    <asp:Panel ID="Panel1" runat="server" CssClass="modal-popup" align="center" Style="display: none">
        <br />
        <br />
        Group Code cannot be empty<br />
        <asp:Button ID="btnClose" runat="server" Text="Close" />
    </asp:Panel>
    <!-- ModalPopupExtender -->
    <script type="text/javascript">
        function launchModal(){
            var id = $find("mp1");
            if (id)
                id.show();
            else
                alert("Not found");
        }

        //var launch = false;
        //function launchModal() {
        //    launch = true;
        //}
        //function pageLoad() {
        //    if (launch) {
        //        $find("mp1").show();
        //    }
        //}
    </script>
</asp:Content>











我的代码背后








My Code Behind

Protected Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        If txtGrpCode.Text = "" Then
            Page.ClientScript.RegisterStartupScript(Me.GetType(), "window-script", "launchModal()", True)
            Response.Redirect("frmFm01det.aspx")
        End If





我尝试过:



我尝试使用javascript(不确定我的语法是否正确)来调用infront函数,但它根本不起作用。我甚至不知道如何调试。



What I have tried:

I have tried using javascript(not sure if my syntax is correct) to call the function infront but it doesn't work at all. I don't even know how to debug.

推荐答案

find(mp1);
if(id)
id.show();
else
alert(Not found);
}

// var launch = false;
//函数launchModal(){
// launch = true;
//}
// function pageLoad(){
// if(launch){
//
find("mp1"); if (id) id.show(); else alert("Not found"); } //var launch = false; //function launchModal() { // launch = true; //} //function pageLoad() { // if (launch) { //


find(mp1 )。节目();
//}
//}
< / script>
< / asp:Content>
find("mp1").show(); // } //} </script> </asp:Content>











我的代码背后








My Code Behind

Protected Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        If txtGrpCode.Text = "" Then
            Page.ClientScript.RegisterStartupScript(Me.GetType(), "window-script", "launchModal()", True)
            Response.Redirect("frmFm01det.aspx")
        End If





我尝试过:



我尝试使用javascript(不确定我的语法是否正确)来调用infront函数,但它根本不起作用。我甚至不知道如何调试。



What I have tried:

I have tried using javascript(not sure if my syntax is correct) to call the function infront but it doesn't work at all. I don't even know how to debug.


Quote:

Page.ClientScript.RegisterStartupScript(...)
Response.Redirect("frmFm01det.aspx")



RegisterStartupScript 告诉页面在呈现页面时输出指定的脚本块。



Response.Redirect 然后告诉页面扔掉所有东西,并发送一个空响应告诉浏览器加载一个不同的页面。



如果你想让脚本运行,你需要删除重定向。


RegisterStartupScript tells the page to output the specified script block when the page is rendered.

Response.Redirect then tells the page to throw everything away, and send an empty response telling the browser to load a different page.

If you want the script to run, you need to remove the redirection.


这篇关于如何从ASP.NET VB背后的代码做modalpopupextender的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆