Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 23rd, 2004, 08:18 AM
Authorized User
 
Join Date: Oct 2003
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
Default Call codebehind function from ASPX

Hi,

I have a function written in vb.net (web application) that I need to call once the user clicks on the html image (I can't use a web control).
However, I get a javascript error 'Object not defined' when I click the image.
What am I doing wrong?
Please note that although I know a web server control would be much easier I can't use such a control on this page and therefore need a solution with a html control.
Thanks

HEADER.ASCX.VB:


<body bgColor="white">

<table cellSpacing="2" cellPadding="0" bgColor="white" border="0">

<tr>

<td><IMG id="IMG1" src="site/empty_b.jpg" border="0" runat="server" onclick="ExitBtn()"></td>

</tr>

</table>




HEADER.VB:


 Public Function ExitBtn()

        Request.Cookies("IBuySpy_FullName").Value = ""

        Response.Cookies("IBuySpy_FullName").Expires = DateTime.Now.AddDays(-1)

        IMG1.Visible = False

        Response.Redirect("default.aspx")

    End Function




 
Old September 2nd, 2004, 03:31 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 142
Thanks: 0
Thanked 2 Times in 2 Posts
Default

As I understand it, you are trying to call a vb function via javascript. Your code will never work, because the page would have to be posted back to the server (where your function resides) before your function could be called. Your function is not embedded in the page, where the browser could 'get at' it. If you want this to work, you'll either have to write the function in javascript (which I think, looking at what you're doing, is pretty simple) or post back to the server.

If you need help writing the function, best to post something in a javascript forum - I'd help but my javascript isn't fantastic and it would take me a while where an experienced javascripter could sort it in moments.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Call to function Awkuzu BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 September 19th, 2007 06:13 PM
Call a Function stealthdevil Access VBA 2 November 2nd, 2006 10:38 AM
calling a codebehind function on onblur event vishnupriya.kamalakaram ASP.NET 1.0 and 1.1 Basics 2 July 7th, 2006 08:25 AM
How to call javascript function from VB function vinod_yadav1919 VB How-To 0 February 13th, 2006 06:03 AM
Calling codebehind C# function from aspx page ravindrasingh77 BOOK: ASP.NET Website Programming Problem-Design-Solution 2 March 16th, 2005 12:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.