简体   繁体   English

asp.net中的网站代码是动态的

[英]Website code in asp.net that is dynamic

I have been assigned a project that seems challenging to do. 我被分配了一个似乎很难完成的项目。 在此处输入图片说明 On this webpage, I want a new section to be added under module* when "computer request" is clicked. 在此网页上,当单击“计算机请求”时,我希望在模块*下添加一个新部分。 The section will be called "cost center" with a textbox on the side to input information. 该部分称为“成本中心”,侧面带有文本框,用于输入信息。 I want it to look like the Subject* line with the textbox but instead of subject i want a new line under module. 我希望它看起来像带有文本框的“主题*”行,但不是主题,我想在模块下添加新行。

All of the data is used dynamically. 所有数据都是动态使用的。 Could anyone point me in the right direction to where to start? 有人能指出我正确的方向从哪里开始吗? Apparently I need to use client side code.. 显然我需要使用客户端代码。

You might like to investigate the UpdatePanel control . 您可能想研究UpdatePanel控件 This might help you do what you need. 这可以帮助您完成所需的工作。

placeholder is a very good choice for your scenario. 占位符是您的方案的很好选择。 It is useful when any user wants to bind a dynamic control and we can fix its position too. 当任何用户想要绑定动态控件时,它也很有用,我们也可以固定其位置。 Very simple demo at : http://www.java2s.com/Code/ASP/Asp-Control/DealwithaspplaceholdercontrolfromcodebehindC.htm 非常简单的演示,位于: http : //www.java2s.com/Code/ASP/Asp-Control/DealwithaspplaceholdercontrolfromcodebehindC.htm

why not create the item on the page and when the value "computer request" is selected, hide or show it? 为什么不在页面上创建项目,并且选择“计算机请求”值时,隐藏还是显示它? You can do this by setting the autopostback property on your dropdownlist to true and can test against it in your code behind. 您可以通过将下拉列表上的autopostback属性设置为true来进行此操作,并可以在后面的代码中对其进行测试。

If you want to do this completely in client-side code, just create the "Cost Center" row and set visibility to false . 如果要完全在客户端代码中完成此操作,只需创建“成本中心”行并将可见性设置为false Then wire up the onchange event of the dropdown list to a javascript function that checks if the "Computer Request" item was selected. 然后将下拉列表的onchange事件连接到javascript函数,该函数检查是否选择了“计算机请求”项。 If it was, change the visibility to true . 如果是,请将可见性更改为true (You could also use jQuery to do this ). (您也可以使用jQuery 来做到这一点 )。

Edit 编辑

$(document).ready(function () {
    $('#yourSelectId').change(function() {
        var selectedVal = $('#yourSelectId option:selected').attr('value');
        if(selectedVal == computerRequestItemValue)
            $('#costCenterRow').show();
        else
            $('#costCenterRow').hide();
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM