1
問題:如何在按下回車鍵時在AjaxControlToolkit組合框中獲取用戶輸入的值?
用戶輸入的值在AjaxControlToolkit ComboBox的。文本屬性缺少當回車鍵按下。此外,「改變」事件不會被調用,但我不使用回發,所以我不在乎。
例子:
private void BuildFileListDetails(NHibernateDataProvider _providerM)
{
int resultsPage = Convert.ToInt32(ddlNavPageNumber.Text);
const int RESULTS_PAGE_SIZE = 100;
// The cbFileName.Text equals "" Not what user entered
string searchFileName= cbFileName.Text;
var xrfFiles = _providerM.GetXrfFiles(searchFileName, resultsPage, RESULTS_PAGE_SIZE);
gvXrfFileList.DataSource = xrfFiles;
gvXrfFileList.DataBind();
}
我的解決方案:
我需要訪問AjaxToolkit 「組合框」 嵌入TextBox控件的。文本訪問由用戶輸入的值。
private void BuildFileListDetails(NHibernateDataProvider _providerM)
{
int resultsPage = Convert.ToInt32(ddlNavPageNumber.Text);
const int RESULTS_PAGE_SIZE = 100;
string searchFileName;
//The Solution: Access the AjaxToolkit "ComboBox" imbedded TextBox control's .Text to access the value entered by user.
TextBox textBox = cbFileName.FindControl("TextBox") as TextBox;
if (textBox != null)
{
searchFileName = textBox.Text; //textBox.Text = "User Entered Value"
}
var xrfFiles = _providerM.GetXrfFiles(searchFileName, resultsPage, RESULTS_PAGE_SIZE);
gvXrfFileList.DataSource = xrfFiles;
gvXrfFileList.DataBind();
}