저는 C#/Net을 사용하여 인트라넷 용으로 작성한이 응용 프로그램을 가지고 있습니다. 한 곳에서 OnLeave 이벤트의 값을 검사하여 일부 입력란을 자동 완성합니다. 문제는 사용자가 필드에서 제출 단추로 직접 이동하면 OnLeave 이벤트가 발생하지만 필드가 채워지지 않는다는 것입니다.어떻게 C# 웹 응용 프로그램을 "따라 잡을"수 있습니까?
VBA의 DoEvents에 대해 생각해 보았습니다. "Application.DoEvents"를 사용하십시오.하지만 시도 할 때 빨간색으로 강조 표시됩니다. 나는 또한 "Render()"라는 것을 발견했다. 그러나 나는 그것을 시도 할 때 푸른 색으로 밑줄을 긋는다.
이 코드를 "따라 잡아"모든 데이터가 올바르게 렌더링되도록 사용자에게 알려줄 수 있습니까? 제 생각에는 아직도 C#에 익숙하지 않습니다. 가능한 한 명시 적/철저한 수 있다면 감사하겠습니다.
편집
나는 텍스트 상자의 OnLeave 이벤트로이 코드를 가지고 :
protected void txtClientID_OnLeave(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(str2))
{
//Query the Reports table to find the record associated with the selected report
using (SqlCommand cmd = new SqlCommand("SELECT * FROM VW_MOS_DPL_AccountValidation WHERE CLIENT_ID = '" + txtClientID.Text + "'", con))
{
con.Open();
using (SqlDataReader DT1 = cmd.ExecuteReader())
{
// If the SQL returns any records, process the info
if (DT1.HasRows)
{
while (DT1.Read())
{
try
{
int TaskID = Convert.ToInt32(ddlTask.SelectedValue);
// This should allow Client ID to autofill if Eligibility --> Enrollment records are used.
// Add more Task IDs to this list if necessary.
List<int> list = new List<int>() { 154, 156, 157, 158, 160, 161, 165 };
if (list.Contains(TaskID))
{
//lblAccountName.Text = (DT1["CUST_NM"].ToString());
Label2.Text = (DT1["CUST_NM"].ToString());
//lblAccountName.Visible = true;
TBAccountNum.Text = (DT1["CUST_NUM"].ToString());
TBAccountNum.Visible = true;
}
}
catch (Exception ae)
{
Response.Write(ae.Message);
}
}
}
// If the SQL returns no records, return a static "No Records Found" message
else
{
//lblAccountName.Text = "No Matching Account Name";
Label2.Text = "No Matching Account Name";
//lblAccountName.Visible = true;
TBAccountNum.Text = "";
}
}
}
}
}
나는 또한 버튼을 제출해야하고, 버튼을 누를 때, 제일 먼저 내가 원하는을 이 OnLeave로 채워지도록되어있는 모든 필드가 실제로 채워지는지 확인해야합니다. 문제는 내가 단계별로 살펴보면 모두 값이 있지만, 방금 실행하면 값이 화면에 나타나지 않습니다. .
"System.Threading.Thread.Sleep (100);" 다른 사이트에서 본 추천에 따르면,하지만 그건 아무 것도하지 않는 것 같습니다.
내가 코드를 게시하는 것이 좋을 것이라고 생각합니다. –
필드가 비어 있으면 제출 클릭시 자동 채우기 코드가 실행됩니까? 어떤 코드 없이는 무슨 일이 벌어지고 있는지 알기가 어렵습니다. –
ASP.NET Web Forms을 사용하고 있습니까? 2014 년에? – bzlm