Applying Conditions for buttons in Multiview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adarshyam
    New Member
    • Oct 2008
    • 31

    Applying Conditions for buttons in Multiview

    hi i am doin a program using multiview, i wanna put if else statement to check a condition in textboxes that i created dynamically. but what happenin is it displays the messagebox as well as changes, pls see my code for better understandin

    currently im in 2nd view n tis s button click event to check condition.. if its numeric then it must goto next view, if not it must display d msg n stay in same view,. but it displays d msg n also goes to the next view.. pls teme wher im goin wrong..

    Code:
                 For cnt As Integer = 0 To textbox1.text - 1               
                              If Not IsNumeric(TxtDyn3(cnt).Text) Then            
                                    MsgBox("Enter only Numbers in Actual Demand")        
                              Else                 
                                    MultiView1.SetActiveView(View3)         
                              End If         
                            Next
  • vanc
    Recognized Expert New Member
    • Mar 2007
    • 211

    #2
    There is chance that those two conditions are met in the loop. If you debug your code, you'll see for sure what's going on.

    Comment

    • balabaster
      Recognized Expert Contributor
      • Mar 2007
      • 798

      #3
      Question: If you fail the condition before your loop completes, do you want it to continue looping? My guess is not...

      Comment

      • adarshyam
        New Member
        • Oct 2008
        • 31

        #4
        sorry, i have changed my mind and i wanna use compare validator for dynamically created textboxes.. Please forget about d prev question . it was really confusing me.. and do i have to create a compare validator in source ? if so what al properties should i add apart from that i have added in code behind. please help me.. and this s what i have done in page_load
        Code:
         For k As Integer = 0 To Textbox1.text - 1
        
                        TxtDyn3(k) = New TextBox
                        TxtDyn3(k).ID = "TxtDyn3_" & k
                        TxtDyn3(k).EnableViewState = True
                        Panel3.Controls.Add(TxtDyn3(k))
                    
                        textdynamic3.Add(textdynamic3)
                        Dim val As New CompareValidator
                        val.ID = "cmpval"
                        Panel3.Controls.Add(val)
                        val.ControlToValidate = "TxtDyn_3" & k
                        val.ErrorMessage = "Enter only Numeric value"
                        val.Display = ValidatorDisplay.Dynamic
                        val.Operator = ValidationCompareOperator.DataTypeCheck
                        val.Type = ValidationDataType.Integer
                        val.SetFocusOnError = True
                        TxtDyn3(k).Width = 60
        
                    Next
        pls teme wher i am goin wrong whether it is in dynamic textbox ID or compare validator ID. and one more thing, these are multiple textboxes created dynamically according to user input. so i need to do validation after al inputs r entered n during the button click.

        Comment

        Working...