<VS03>How to make the textbox text remain after postback

Joined
Feb 10, 2009
Messages
2
Reaction score
0
Hi All,

I design a datagrid which enabled user to edit,delete and add new record inside the grid.

The add button and textbox control embeded in datagrid footer section.

I want to do a validation when user trying to insert new record into database.

What I want to do is check if templatecolumn textbox is blank then pop up a messagebox and

setfocus to textbox until this stage all is fine but when everything completed the page will postback and

reload the text inside textbox and cleared.

I don't want the text inside the textbox clear after BLANK found. It will remain inside the textbox with

unchanged.

Hereon, I posted my html code and code behind.

PHP:
<body ms_positioning="GridLayout" id="myBody" runat="server">


PHP:
Private Sub dgSchoolName_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgSchoolName.ItemCommand
        Dim pStrSql As String, myds As New DataSet, mydt As DataTable
        Dim Txtbox As TextBox = DirectCast(e.Item.Cells(1).FindControl("txtSchoolNo"), TextBox)
        Dim Txtbox_1 As TextBox = DirectCast(e.Item.Cells(2).FindControl("txtSchoolNameA"), TextBox)
        Dim FTextbox As String = Txtbox.Text
        Dim FTextbox_1 As String = Txtbox_1.Text
        Dim myBody As System.Web.UI.HtmlControls.HtmlGenericControl = CType(Page.FindControl("myBody"), System.Web.UI.HtmlControls.HtmlGenericControl)

        If FTextbox = vbNullString Then
            General_F.Setfocus(Txtbox, Page, "Form1")

            MsgBox1.alert("School No Cannot Be Blank")

            Exit Sub
        ElseIf FTextbox_1 = vbNullString Then
            General_F.Setfocus(Txtbox_1, Page, "Form1")
            MsgBox1.alert("School Name Cannot Be Blank")

            myBody.Attributes.Add("onload", "document.getElementById('txtSchoolNo').value = '" & FTextbox & "'")

        Exit Sub
        End If
End Sub

I have been posted my code above. I hope someone can help me thanks :)
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top