ASP.NET中的断点问题

发布于 2024-08-23 19:38:35 字数 2801 浏览 8 评论 0原文

我已经在网络用户控件中发布了一个断点。但 Control 并没有进入断点。为什么会出现这种情况。 我已经完成了内联代码。

<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="IBlog.Web.HandleUserControl" %>

<script language="C#" runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        Pagemenu.pageload();
    }
    public string Geturl(string url)
    {
        return Pagemenu.Geturl(url);
    }
    protected void menu1_MenuItemClick(object sender, MenuEventArgs e)
    {
        Pagemenu.menu1_MenuItemClick(sender, e);
    }

    //protected void Page_SelectedIndexChanged(object sender, EventArgs e)
    //{
    //    Pagemenu.Page_SelectedIndexChanged(sender, e);

    //}

    //protected void MoreClick(object sender, EventArgs e)
    //{
    //    DataList2.Visible = true;

    //}

    protected void lbmore_Click(object sender, EventArgs e)  //this is the code i want to debug
    {

    }
</script>

 <script type="text/javascript">
    function mover()
    {
    var elem = document.getElementById("<%= DataList2.ClientID %>");
    elem.style.display="block"

    }
    function mout()
    {
    var elem = document.getElementById("<%= DataList2.ClientID %>");
    elem.style.display="none" 
    }

</script>

<div class="navi">
    <div class="pages">
        <ul>
            <asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal">
                <ItemTemplate>
                    <li><a href='<%#Geturl((string)DataBinder.Eval(Container.DataItem, "URL"))%>'>
                        <%# DataBinder.Eval(Container.DataItem, "Title") %>
                    </a></li>
                </ItemTemplate>
            </asp:DataList>
        </ul>
    </div>
     <asp:LinkButton ID="lbmore" runat="server" Text="More" OnClick="lbmore_Click"></asp:LinkButton>
    <div class="pages2" id="more" runat="server">

        <%--<a href="" onmouseover="mover()" onmouseout="mout()">More</a>--%>
        <ul style="background-color: #626669; padding: 0 6px 0 6px; margin: 28px 0 0 0px">
            <asp:DataList ID="DataList2" runat="server" Visible="false">
                <ItemTemplate>
                    <li style="float: left;"><a href='<%#Geturl((string)DataBinder.Eval(Container.DataItem, "URL"))%>'>
                        <%# DataBinder.Eval(Container.DataItem, "Title") %>
                    </a></li>
                </ItemTemplate>
                <ItemStyle Wrap="True" />
            </asp:DataList>
        </ul>

    </div>
</div>

I've posted a breakpoint in web user control. But Control is not going on breakpoint. Why is this happening.
I have done inline code.

<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="IBlog.Web.HandleUserControl" %>

<script language="C#" runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        Pagemenu.pageload();
    }
    public string Geturl(string url)
    {
        return Pagemenu.Geturl(url);
    }
    protected void menu1_MenuItemClick(object sender, MenuEventArgs e)
    {
        Pagemenu.menu1_MenuItemClick(sender, e);
    }

    //protected void Page_SelectedIndexChanged(object sender, EventArgs e)
    //{
    //    Pagemenu.Page_SelectedIndexChanged(sender, e);

    //}

    //protected void MoreClick(object sender, EventArgs e)
    //{
    //    DataList2.Visible = true;

    //}

    protected void lbmore_Click(object sender, EventArgs e)  //this is the code i want to debug
    {

    }
</script>

 <script type="text/javascript">
    function mover()
    {
    var elem = document.getElementById("<%= DataList2.ClientID %>");
    elem.style.display="block"

    }
    function mout()
    {
    var elem = document.getElementById("<%= DataList2.ClientID %>");
    elem.style.display="none" 
    }

</script>

<div class="navi">
    <div class="pages">
        <ul>
            <asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal">
                <ItemTemplate>
                    <li><a href='<%#Geturl((string)DataBinder.Eval(Container.DataItem, "URL"))%>'>
                        <%# DataBinder.Eval(Container.DataItem, "Title") %>
                    </a></li>
                </ItemTemplate>
            </asp:DataList>
        </ul>
    </div>
     <asp:LinkButton ID="lbmore" runat="server" Text="More" OnClick="lbmore_Click"></asp:LinkButton>
    <div class="pages2" id="more" runat="server">

        <%--<a href="" onmouseover="mover()" onmouseout="mout()">More</a>--%>
        <ul style="background-color: #626669; padding: 0 6px 0 6px; margin: 28px 0 0 0px">
            <asp:DataList ID="DataList2" runat="server" Visible="false">
                <ItemTemplate>
                    <li style="float: left;"><a href='<%#Geturl((string)DataBinder.Eval(Container.DataItem, "URL"))%>'>
                        <%# DataBinder.Eval(Container.DataItem, "Title") %>
                    </a></li>
                </ItemTemplate>
                <ItemStyle Wrap="True" />
            </asp:DataList>
        </ul>

    </div>
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一绘本一梦想 2024-08-30 19:38:35

你有一个空方法 - 框架不允许你在其中附加调试器,因为没有什么可做的 - 编译器将优化该代码库,因为该方法中没有代码。

您是否尝试过在方法中添加一些简单的代码来强制它执行某些操作(例如声明、设置和查看变量)?

编辑以回复评论

您已在 web.config 中指定 debug="true",并且已将 Visual Studio 附加到网站(通过在 VS 中按 F5加载项目,或通过“调试|附加到进程...”)?

您正在构建一个 Web 应用程序(您必须编译该项目才能看到代码中的更改,您的根目录中有一个 /bin 文件夹,其中有一个 dll)或一个网站(您不必编译东西,您有用于共享类等的 /app_code 文件夹)。

You've got an empty method - the framework won't allow you to attach a debugger in there, as there's nothing to do - the compiler will have optimised that code base out, as there's no code in the method.

Have you tried adding some simple code in the method to force it to do something (declare, set and view a variable for example)?

Edit to respond to comments

You have specified debug="true" in your web.config, and you have attached Visual Studio to the web site (either by pressing F5 in VS with the project loaded, or through "Debug | Attach to process...")?

Are you building a Web Application (you have to compile the project to see changes in code, you have a /bin folder in the root with a dll in in) or a web site (you don't have to compile things, you have an /app_code folder for shared classes, etc).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文