2013-03-16 92 views
0

我目前使用FormView來顯示一個使用我的數據庫的表單。我在formview中添加了一個customvalidator,並希望使用c#來驗證用戶輸入。訪問CustomValidator isValid屬性 - Visual Studio 2008

作爲文本框的形式是視圖我已經使用到下面的代碼來訪問輸入:

String phoneNum = (FormView1.FindControl("NumberTextBox") as TextBox).Text; 

而下面的訪問自定義驗證:當我使用customValidator1

Control CustomValidator1 = FormView1.FindControl("CustomValidator1"); 

.isValid,我得到「不包含定義isValid」

我想知道是否有一種方法來使用isValid屬性,並且我訪問了customvalidat或正確?

感謝:P

回答

0

嘗試投射CustomValidator1到它的類型不控制。

+0

不好。 「無法找到類型或名稱空間名稱'自定義驗證器1'」。謝謝反正:) – user2177496 2013-03-16 17:31:24

+0

是啊..它不是一個CustomValidator1,但一個CustomValidator ... – 2013-03-18 18:10:39