从列表框dropdownextender填充后,文本框值保留问题. [英] Textbox Value Retaining Problem after populating from Listbox dropdownextender.

查看:101
本文介绍了从列表框dropdownextender填充后,文本框值保留问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的代码中使用了2个TextBoxes,2个Listboxes和一个按钮.

textbox1-名字
textboox2-姓氏
listbox1-从MS Access的Emp表填充 listbox2-从MS Access的Emp表填充 Button1-获取输入的名称的详细信息,并显示在某些标签的同一页上.

TextBox1具有一个从listBox1填充的dropdownextender,而TextBox2具有一个从ListBox2填充的dropdownextender.

我做了javascript代码,所选值现在显示在各个文本框上,如下所示:

Hi,

I have my code wherein I have used 2 TextBoxes , 2 Listboxes and a button.

textbox1 - First Name
textboox2- Last Name
listbox1 - Populated from Emp table in MS Access
listbox2 - Populated from Emp table in MS Access
Button1 - to fetch details of name entered and display on same page on some labels.

TextBox1 has a dropdownextender which is populated from ListBox1 and TextBox2 has a dropdownextender which is populated from ListBox2.

I did the javascript code and the selected value is now showing onto the respective textboxes as below:

//In code behind..
ListBox1.Attributes.Add("onclick", "setText1(this.options[this.selectedIndex].value);");
            ListBox2.Attributes.Add("onclick", "setText2(this.options[this.selectedIndex].value);");

//In source code
function setText1(newValue) 
{
    document.getElementById("<%=txtbx_Firstname.ClientID %>").value = newValue;
}
function setText2(newValue1) 
{
    document.getElementById("<%=txtbx_Lastname.ClientID %>").value = newValue1;
}




问题:
当我单击按钮"以获取输入名称的详细信息时,文本框将被清除.因此,我无法在文本框值和数据库值之间进行比较.

请帮助如何保留文本框值并在我的代码中使用.

我的整个页面功能取决于此.




Problem:
When I click the Button to fetch details of entered name, the textboxes gets cleared. due to this, I am not able to make a comparison between the textbox values and database values.

Please help how to retain the textbox values and use in my code.

My full page functionality depends on this.

推荐答案

从代码中看来,您希望用户从数据库中可用的数据中选择名字和姓氏值.显示在列表框中.我认为组合框控件可能适用于此目的,ASP.net网站上的以下ASP.net AJAX控件工具包示例可能对您有所帮助

http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ComboBox/ComboBox.aspx [ ^ ]

如果您的问题得到解决,则可以接受该解决方案并对其进行表决,否则,请发布您的查询

PES
From the code it seems that you want the user to select the first name and last name values from the data available in database which is displayed in listboxes. I think combo box control may be suitable for this purpose and the following samples of ASP.net AJAX control toolkit on ASP.net website may be helpful to you

http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ComboBox/ComboBox.aspx[^]

If your problem is solved, you may accept and vote the solution, otherwise please post your queries

PES


这篇关于从列表框dropdownextender填充后,文本框值保留问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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