1

I am new to jqueries and I have a problem calling a dialog box If ever my user has an invalid search query and did not put a starting date. See I have this jquery code

$(function(){          
  $("#dialog").dialog(function() {                                    
     $("#dialog").dialog()};
  });
});

Now I have these codes in vb :

 Sub Subsearch()
    If txtfrom.Text <> "" And txtto.Text <> "" Then
        //some codes

    ElseIf txtfrom.Text <> "" And txtto.Text = Nothing Then
        //some codes

    ElseIf txtfrom.Text = Nothing And txtto.Text <> "" Then

        //call my JQuery 

    Else
        // some codes

    End If
End Sub

Now how do I do this?

4
  • try to wrap your jqery in a string and then print that string with the help of response.write for instance. Dim myJquery as string ="$(function(){$("#dialog").dialog(function() {"#dialog").dialog()};}); });" make sure they are all in a same line and now do respose.write(myJquery) Commented Feb 6, 2013 at 6:42
  • How to do that? I'm really new at this sorry Commented Feb 6, 2013 at 6:44
  • Its ok but have you called jquery then jquery-ui then put this code and in this code you have one extra }. Commented Feb 6, 2013 at 6:45
  • Yes i have called the jquery and jquery-ui.. Commented Feb 6, 2013 at 6:58

3 Answers 3

4

Try this:

Update to VB.NET

ClientScript.RegisterClientScriptBlock(Me.[GetType](), "blah", "myfunction();", True

If you're using a ScriptManager, use RegisterStartupScript(), use it this way:

ScriptManager.RegisterStartupScript(this, GetType(), "modalscript",
"$(function() { $('#dialog').dialog(); });", true);
Sign up to request clarification or add additional context in comments.

7 Comments

Do i put this after the elseif ? it says "this" is not declared
How do I name my function? Or know its name
add something like myfunction() which is a name given to a function between your function{ as $(function myfunction()
I tried putting the first one but the ";" and "this" are underlined blue
Hi @coder.. I have tried this near to your code ClientScript.RegisterClientScriptBlock(Me.GetType(), "error", "myfunction();", True) and it worked I alse added this $('#dialog').dialog('open'); and autoOpen:false; It works already now my problem is it appears every page load.. but also appears when the validation is met
|
0
dim myjquery as string="$(function(){ $('#dialog').dialog(function() {$('#dialog').dialog()} ;  }); });"
response.write(myjquery)

Let me know if it works or not

1 Comment

the "#" sign turns blue and then an error saying "End of statement expected" comes out
-2

you could use the JQuery to validate your input boxes, thereby not having to use the VB code to do it...

http://docs.jquery.com/Plugins/Validation

http://speckyboy.com/2009/12/17/10-useful-jquery-form-validation-techniques-and-tutorials-2/

2 Comments

jQuery validation is not a substitute for server-side validation.
You weren't talking about adding an 'extra layer' of validation. You wrote, "thereby not having to use VB code to do it." Client-side validation should be for user experience purposes only - not as a replacement for server-side validation. If you are only implementing client-side validation then I can bypass it completely simply by switching Javascript off. Then, I can post whatever values I want, which, depending on the scenario, could open the way to devastating attacks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.