需要使用Javascript来保存动态控制值 [英] need Javascript for saving Dynamic Control values

查看:109
本文介绍了需要使用Javascript来保存动态控制值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我们有一个ASP.net网页.基于下拉类别选择,控件应填充在页面中.控件从文本框,下拉列表,检查框列表等变化.单击保存时,应将这些动态创建的控件值保存到数据库中.
当前的问题是,当您单击插入时,这些控件在回发中消失了,并且我无法获取这些控件的值.
Prasad

Hello,
We have one ASP.net Web page. Based on the dropdown category selection, controls should be populated in the page. Controls vary from textbox, dropdownlist, chekbox list and so on. When save is clicked, these dynamically created controls values should be saved to the database.
The present issue is when you click insert, these controls are vanished in the postback and I am not able to get the values of these controls.
Prasad

推荐答案

尝试创建Controls OnInit事件.

这样就可以克服控制消失的问题.

为您提供了示例代码:

Try creating the Controls OnInit event.

Then you can overcome the control vanishing problem.

Provided you a sample code :

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    if (ddlList.selectedValue = "your value")
    {
        CreateControls();
    }
    else
    {
        pnlContainer.Controls.Clear();
    }
}



CreateControls方法将用于在页面上创建控件.

希望这会有所帮助.



CreateControls method will be used to create controls on your page.

Hope this helps.


这篇关于需要使用Javascript来保存动态控制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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