|
-
May 22nd, 2005, 11:37 PM
#1
Thread Starter
Addicted Member
[RESOLVED] HOW to write Javascript in VB.NET?
how can i write if statment in javascript that returns true or false values to vb.net
i mean.. how can i do it to look like the following
javascript code:if (confirm('Are you sure you want to book an appiontment??'))
{return true;
do some VB.NET Code
} else {
return false;
Do some other VB.NET Code
};
Please help...
Last edited by NinaWilliam; Mar 8th, 2006 at 02:04 AM.
-
May 23rd, 2005, 11:22 PM
#2
Thread Starter
Addicted Member
Re: HOW to write Javascript in VB.NET?
come on guys... help me
-
May 24th, 2005, 02:07 AM
#3
Re: HOW to write Javascript in VB.NET?
You cannot. Instead, you'll have to submit the page with a hidden value set somewhere, so that vb.net can look at it and perform appropriate actions.
-
May 24th, 2005, 02:20 AM
#4
Lively Member
Re: HOW to write Javascript in VB.NET?
 Originally Posted by NinaWilliam
how can i write if statment in javascript that returns true or false values to vb.net
i mean.. how can i do it to look like the following
javascript code:if (confirm('Are you sure you want to book an appiontment??'))
{return true;
do some VB.NET Code
} else {
return false;
Do some other VB.NET Code
};
Please help...
This is not possible, as far as my knowledge goes. You have to separate the Javascript function in the aspx page and store the return value in some hidden field. Call the javascript method in the button click using attributes.add and check for the return value in the hidden field in the event handler for the button.
Hope this helps.
Everything I code, is a piece for Museum.
-
May 24th, 2005, 06:35 AM
#5
Thread Starter
Addicted Member
Re: HOW to write Javascript in VB.NET?
thanks..but can you show me the code please?? i really need your help guys
-
May 24th, 2005, 06:38 AM
#6
Re: HOW to write Javascript in VB.NET?
VB Code:
If blnSomeCondition Then
Page.RegisterStartupScript(.....)
Else
Page.RegisterStartupScript(........)
End If
-
May 24th, 2005, 06:45 AM
#7
I wonder how many charact
Re: HOW to write Javascript in VB.NET?
Code:
<head>
<meta...
...
...
<script language="javascript" type="text/javascript">
function DoSomething()
{
if (confirm("Do you wish to continue?"))
{
document.getElementById('hiddenChoice').value = 1;
document.forms[0].submit;
}
else
{
document.getElementById('hiddenChoice').value = 0;
document.forms[0].submit;
}
}
</script>
</head>
<body>
<form id="Form1" runat="server">
<input type="hidden" runat="server" id="hiddenChoice" />
<input type="button" id="launch" onclick="DoSomething()" />
....
In your code-behind:
VB Code:
'declerations section
Protected hiddenChoice As System.Web.UI.HtmlControls.HtmlInputHidden
Private Sub hiddenChoice_ServerChange (Sender As System.Object, e As System.EventArgs)
If hiddenChoice.Value = 1
'do some code
Else
'do some other code
End If
End Sub
Last edited by nemaroller; May 24th, 2005 at 06:48 AM.
-
May 24th, 2005, 06:51 AM
#8
I wonder how many charact
Re: HOW to write Javascript in VB.NET?
You could also use an XMLHTTP request, but that is probably more involved than using a hidden input field.
-
Mar 8th, 2006, 02:03 AM
#9
Thread Starter
Addicted Member
Re: HOW to write Javascript in VB.NET?
hmmmmmmm... thats good.. very good code.
thanks and happy programming
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|