0

I have a js function called by an onclick event in a radio button. If i put the function in the same ascx where the radio button is defined, the function is not called. So i tried to put it on the ascx which includes the ascx with the button and it works, but i have this error on the debugger :

Failed to load resource: net::ERR_NAME_NOT_RESOLVE

Here is the function:

  <script>
function UcSelect() {
    var value = $("#rbtTipo :checked").val();
    if (value == 'E') {
        alert("aaaaaaaaaaaaa");
    }
    if (value == 'G') {
        alert("bbbbbbbbbbbbbbbbbb");
    }
    return true;
}

4
  • Do you get the same error in all browsers? Commented Jun 22, 2015 at 12:47
  • You can only use rbtTipo like that in the control that has that property in its code behind, i.e. only in the control where the radio button is defined. If you want to use it somewhere else you need to expose that property publicly in that control and access it using a reference to that control. That's why you get the error that the name doesn't resolve. I think that you should put the function back in the control where the radio button is, and try to find out why that didn't work for you. Commented Jun 22, 2015 at 12:51
  • @Guffa, yes sorry i'm going to edit the code, this is a copy past of a previous version, in the current one i have the correct statement Commented Jun 22, 2015 at 13:24
  • Then the error is not related to the actual code at all, but a network error in Chrome. Either you have an URL that is wrong, or Chrome is stuck trying to load proxy settings. For the second case the usual fix is to stop Chrome from trying to use a proxy, see How can I fix "Error 105 (net::ERR_NAME_NOT_RESOLVED): The server could not be found." on Chrome?. Commented Jun 22, 2015 at 14:07

1 Answer 1

0

Use Else function its miss u r code

<script>
    function UcSelect() {
        var value = $("#<%= rbtTipo.ClientID %> :checked").val();
        if (value == 'E') {
            alert("aaaaaaaaaaaaa");
        }
    else 
        if (value == 'G') {
            alert("bbbbbbbbbbbbbbbbbb");
        }
        return true;

}

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, but this will not fix my probl