Click here to Skip to main content
15,919,245 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have 4 Textboxes in a payment_transfer screen:

==============================
debit_customer  : TextBox1
payment_number  : Textbox2
credit_customer : Textbox3
amount          : Textbox4


In this, every time I entered the value in textboxes and click on screen, the page gets refreshed and the cursor will be focused to debit_customer textbox every time.

Now my PROBLEM is Textbox Focus Problem...
When I give the credit_customer value and click on screen and screen refreshes, then the cursor should be focused to amount textbox.

Please help me.

Thanks.

What I have tried:

ASP.NET
protected void Page_Load(object sender, EventArgs e)
        {
            Master.InfoMsg = "";
            if (!Page.IsPostBack)
            {
                Master.Title = GetStrResource("pmt_trn");
                Master.FormId = 742;
                hdnuserid.Value = Master.UserId.ToString(); 
                DataBind();
                paymentfield.Visible = false;
                tdsfield.Visible = false;
                this.btnsave.Attributes.Add("onclick", 
                "javascript: if (validateForm()){this.disabled = true;}
                 else {return false;}");
                this.btnstage.Attributes.Add("onclick", 
                "javascript: if (validateForm()){this.disabled = true;}
                 else {return false;}");
                uxPayDt.Value = Convert.ToDateTime(Session["VALUEDATE"]).ToString
                (Master.GetProfileSetting("DATEFORMAT"), 
                 CultureInfo.CurrentUICulture);
                /* Drop down code*/
                AppvaluelistSvc vl1 = new AppvaluelistSvc(Master.userInfo);
                DataTable dt1 = vl1.GetValuelistValues("PMTTDSTRANSFER");
                if (vl1.status.errcode != 0)
                {
                    vl1 = null;
                    return;
                }

                if (dt1 != null && dt1.Columns.Count > 0)
                {
                    dt1.Rows.InsertAt(dt1.NewRow(), 0);
                    transferdropdown.DataSource = dt1.DefaultView;
                    transferdropdown.DataValueField = dt1.Columns[0].ColumnName;
                    transferdropdown.DataTextField = dt1.Columns[1].ColumnName;
                    transferdropdown.DataBind();
                }
                SetGridsSource();
                if (Request.QueryString["PYMT_TRANSFER_ID"] != null 
                    && Request.QueryString["PYMT_TRANSFER_ID"] != "0")
                {
                    Master.Title = GetStrResource("edit_pmt_trns");
                    hdnpymttrnsid.Value = 
                                  Request.QueryString["PYMT_TRANSFER_ID"];
                    if (Request.QueryString["REF_TXN_TYPE"] != null 
                        && Request.QueryString["REF_TXN_TYPE"] != "0")
                    {
                        transferdropdown.SelectedValue = 
                                         Request.QueryString["REF_TXN_TYPE"];
                    }
                    SetValues(Convert.ToInt64(hdnpymttrnsid.Value), 
                              Request.QueryString["action"]);
                }
                else
                {
                    Master.FormMode = "I";
                    BindDetails(1);
                }
            }
            if (custnbr.Value != "" && custnbr.Value != null )
                SetCustomerName(custnbr.Value);
        }
Posted
Updated 25-Jan-22 4:13am
v5
Comments
Richard Deeming 24-Jan-22 8:49am    
There's nothing in the code you've shown which would cause the page to post back when you click on the screen. Nor is there anything that would set the focus to a specific textbox.

1 solution

In Postback scenario, you can also set the focus of control like:
Page.SetFocus(ControlID);
Page.FindControl(ControlID).Focus();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900