I'm having a page that contains REQUIRED FIELD VALIDATOR and a REGULAR EXPRESSION VALIDATOR. When i click on the button, i need certain things to happen if the page.isValid()=true and some other things to happen when the page.isValid=false.
My problem is ,if validators doesn't work in that page, then the code inside "if(page.isValid()=true)" works but the else part doesn't work if the validators are working.
Hi there. I'm not clear about your problem, to tell the truth. Basically, the Page.IsValid is true when the server side validation succeeds, otherwise it's false. And in the button's click event handler, you can do a simple checking and decide what you should do next. Btw, code snippets could help.
Below given is the code where i 've encountered a problem:
Sub btnclk_Click(sender As Object, e As EventArgs)
if page.isvalid then
Response.write("ALL IS WELL")
'doesn't get executed when page contains errors
When validators work in a page, "page.isvalid" will be false. But here , if the validators doesn't work then "ALL IS WELL" is printed , if it works ie,if there is some errors in the page the "else" part doesn't work.
I want the else part to work. If there is no way, can you suggest a way in which i can execute some code when a page contains some errors in .
I guess you are a bit confused here. The value of the Page.IsValid depends on whether the server side validation succeeds or not, it means that the validators always work and if the validation performed by the validators at the server side succeeds, then the Page.IsValid is set to true, otherwise the value is false for example the control to validate contains an invalid value and as a result the else part will be working. And it does not have any thing to do with any errors occur in the web page. So what are the errors that you are talking about?
If you want to handle any errors that occur in the web page, you can create an event handler for the Page_Error event to handle the error and display a friendly error message. You can also specify an error page for the web page in the ErrorPage attribute of the Page directive or the Page instance.
I have some code which makes a call to a remote webservice and uploads a file using DIME. The code runs fine until I try to run it behind a proxy server.
The error I get (only behind proxy) is as follows:
Exception : System.Net.WebException: The underlying connection was closed: Unable to connect to the remote server.
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object parameters)