Cloud
Cloud

Reputation: 213

Website code in asp.net that is dynamic

I have been assigned a project that seems challenging to do. enter image description here 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..

Upvotes: 0

Views: 239

Answers (4)

Marcus
Marcus

Reputation: 5457

If you want to do this completely in client-side code, just create the "Cost Center" row and set visibility to false. Then wire up the onchange event of the dropdown list to a javascript function that checks if the "Computer Request" item was selected. If it was, change the visibility to true. (You could also use jQuery to do this).

Edit

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

Upvotes: 0

Ric
Ric

Reputation: 13248

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.

Upvotes: 0

NG.
NG.

Reputation: 6073

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

Upvotes: 0

Sprintstar
Sprintstar

Reputation: 8169

You might like to investigate the UpdatePanel control. This might help you do what you need.

Upvotes: 1

Related Questions