I have a repeater with asp textbox and asp buttons. The user will enter a value to the textbox and click the button to process. OnClick event (let say rptrButton), I will validate the textbox value and if that value needs additional validation i will show a modal with another asp button (let say button2). My issue is sometimes I'm losing the info that i have assigned to button2 via command argument. What could be the issue? Here's a sample of my logic in the program.
rptrButton click event here's how i'm assigning a value to button2 command argument. So i wrap the button with If condition to make sure that i have the info. And if not i know that i was not able to save the info to the button. So the exception here never got thrown so it means that the info was always succesfully assigned, right?
If Not String.IsNullOrEmpty(value) Then
button2.CommandArgument = value
Else
Throw New Exception
End
button2 command event but here there times that this exception get thrown. Somehow on postback (onclick button2) i'm losing the value in button2 command argument. At first I'm getting the info from CommandEventArgs but same error so i changed it to button but still losing the value.
Protected Sub button2_Command(sender As Object, e As CommandEventArgs) Handles button2.Command
Dim btn As Button = CType(sender, Button)
If Not String.IsNullOrEmpty(btn.CommandArgument) Then
//process
Else
Throw New Exception
End If
End Sub