Code language = VB. ASP.NET 4.0
I have a formview control on my page defaulted to insert mode so when the page loads the only thing you can do is insert a records. I have a bound dropdownlist that defaults to the value of “none”..This can be classified as leave type.. Then I have next to that a textbox classified as hours..
I want to validate that is someone enters time for the textbox that they must choose a value from the dropdownlist.
once I get this far, I then have to repeat it threee times, So I would like to find a way to also write the control either grouping or referencing multiple controls.
If txtbox1.text > 0 then dropdownlist1.selected value must be >0
I could possibly get close just starting there but I find working in asp with the formview control a bit difficult to actually find the control. I have to use the following statements to work with any controls which is a pain
directcast(formview1.findcontrol(“textbox1”), textbox).text
To make it easier: do something like this:
The idea: get all the values you need to test in a convenient form up front, then implement your logic. This will make your logic simpler because you won’t be distracted by the finding-and-casting you have to do.
Actually, you could wrap all that in the ServerValidate event of a CustomValidator.