473,785 Members | 2,298 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Call function in codebehind from jscript in aspx page

I'm using vb.net and have an aspx page where I want to call a function in
the code behind to do something on the backend and I want to call this
function from a jscript function in the aspx page. Furthermore I know there
will be a postback involved but the state of the page will not change at all
so I would like it to be as efficient as possible with no appearance to the
user that anything happened.

I saw in someone else's code where they achieved this by clicking on a <a>
tag that had an href attribute in it like this:
<a title="Add To Shopping Cart" href="<%#
HRefForSKU(Data Binder.Eval(Con tainer.DataItem , "SKU1"))%>" >

however in my case I don't want to put the href attribute in the <a> element
because it puts a line under all the text which we don't want. Instead I
was going to put in a onclick event that would pass a parameter to a jscript
function that would then try to do the same thing as the href attribute
above.

Any ideas?

--
mo*******@nospa m.com
Nov 18 '05 #1
2 3050
Hi Moondaddy,

Let me play around with this tonight and I'll post back tomorrow.

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
ja******@online .microsoft.com

This post is provided as-is with no warranties and confers no rights.

--------------------
From: "moondaddy" <mo*******@nosp am.com>
Subject: Call function in codebehind from jscript in aspx page
Date: Thu, 26 Feb 2004 16:45:00 -0600
Lines: 26
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <Oq************ **@TK2MSFTNGP10 .phx.gbl>
Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
NNTP-Posting-Host: adsl-67-65-189-44.dsl.hstntx.s wbell.net 67.65.189.44
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:2140 97
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet

I'm using vb.net and have an aspx page where I want to call a function in
the code behind to do something on the backend and I want to call this
function from a jscript function in the aspx page. Furthermore I know therewill be a postback involved but the state of the page will not change at allso I would like it to be as efficient as possible with no appearance to the
user that anything happened.

I saw in someone else's code where they achieved this by clicking on a <a>
tag that had an href attribute in it like this:
<a title="Add To Shopping Cart" href="<%#
HRefForSKU(Dat aBinder.Eval(Co ntainer.DataIte m, "SKU1"))%>" >

however in my case I don't want to put the href attribute in the <a> elementbecause it puts a line under all the text which we don't want. Instead I
was going to put in a onclick event that would pass a parameter to a jscriptfunction that would then try to do the same thing as the href attribute
above.

Any ideas?

--
mo*******@nosp am.com


Nov 18 '05 #2
Hi Moondaddy,

There are a few ways I've turned up that will allow you to do this:

1) Call __doPostBack explicitly to fire server side events.
2) Use a hidden form field to hold function information and then call a
function on the server based upon the value of that form field.

The final method is the best choice (only choice really) if you don't want
to cause a postback when the server-side function is called. It involves
using the WebService behavior and calling it from DHTML.

http://msdn.microsoft.com/library/de...us/dndude/html
/dude01222001.as p

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
ja******@online .microsoft.com

This post is provided as-is with no warranties and confers no rights.
--------------------
X-Tomcat-ID: 749474865
References: <Oq************ **@TK2MSFTNGP10 .phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: ja******@online .microsoft.com (Jim Cheshire [MSFT])
Organization : Microsoft
Date: Thu, 26 Feb 2004 23:55:45 GMT
Subject: RE: Call function in codebehind from jscript in aspx page
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
Message-ID: <y0************ **@cpmsftngxa06 .phx.gbl>
Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
Lines: 51
Path: cpmsftngxa06.ph x.gbl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:2141 11
NNTP-Posting-Host: tomcatimport2.p hx.gbl 10.201.218.182

Hi Moondaddy,

Let me play around with this tonight and I'll post back tomorrow.

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
ja******@onlin e.microsoft.com

This post is provided as-is with no warranties and confers no rights.

--------------------
From: "moondaddy" <mo*******@nosp am.com>
Subject: Call function in codebehind from jscript in aspx page
Date: Thu, 26 Feb 2004 16:45:00 -0600
Lines: 26
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <Oq************ **@TK2MSFTNGP10 .phx.gbl>
Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
NNTP-Posting-Host: adsl-67-65-189-44.dsl.hstntx.s wbell.net 67.65.189.44
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:2140 97
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet

I'm using vb.net and have an aspx page where I want to call a function in
the code behind to do something on the backend and I want to call this
function from a jscript function in the aspx page. Furthermore I know

there
will be a postback involved but the state of the page will not change at

all
so I would like it to be as efficient as possible with no appearance to theuser that anything happened.

I saw in someone else's code where they achieved this by clicking on a <a>
tag that had an href attribute in it like this:
<a title="Add To Shopping Cart" href="<%#
HRefForSKU(Da taBinder.Eval(C ontainer.DataIt em, "SKU1"))%>" >

however in my case I don't want to put the href attribute in the <a>

element
because it puts a line under all the text which we don't want. Instead I
was going to put in a onclick event that would pass a parameter to a

jscript
function that would then try to do the same thing as the href attribute
above.

Any ideas?

--
mo*******@nos pam.com



Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
4214
by: chirs | last post by:
I am trying to understand a piece of code. In a javascrpit file, there is a function: function ItemStyle(){ var names=; addProps(this,arguments,names,true); }; In the html file, it calls the function as:
1
5079
by: cheezebeetle | last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when they press "Cancel" they call another ASPX function. My code now is: System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf) System.Web.HttpContext.Current.Response.Write("if (confirm('Are you sure you want to...
0
1848
by: Prescott | last post by:
I want to execute a javascript function that will set a value in the parent window from the child widow where its called and then post the form to the server. I seem to be able to execute one or the other but not both. The child page (html) code is: <%@ Page Language="vb" AutoEventWireup="false" Codebehind="AddKeyWord.aspx.vb" Inherits="ComponentSearch.AddKeyWord"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML>...
8
4832
by: Jade | last post by:
I saw some web page saying I could do it this way in javascript: var iNumber = <%#publicvarname publicpropertyname %> but it doesn't seem to work. I have this piece of code here in javascript: <script language="javascript"> var sessionServer = "<%#jsTestServer%>"; alert(sessionServer); </script>
6
1402
by: Karl Hungus | last post by:
Im using an xsl transformation so its not practical to use controls in the usual way, but I would still like to call methods in my codebehind class. usually Id just use onclick="<eventHandler>" say for something like a button control is there a way to manually call a method defined in a codebehind class, but is not called by a standard control? I looked at the __doPostBack() function that .net generates but it seemed impenetrable.
5
8730
by: Columbia Pike | last post by:
Hi, I'm trying to have a login page; after logging in the user has to see the list of SQL Server Databases available to him/her. I'm always getting the error 'ASP.login_aspx' does not contain a definition for 'btnSignIn_Click' I have the btnSignIn_Click function defined in a codebehind .cs file - The file name is Connect.aspx.cs. I made a DLL and have that DLL in the Bin subfolder (Bin\Connect.dll). Here's the command I used for...
4
4220
by: Zuel | last post by:
Hi Folks. So I have a small problem. My DoPostBack function is not writen to the HTML page nor are the asp:buttons calling the DoPostBack. My Goal is to create a totaly dynamic web page where the server generates the HTML based on a passed in parameter. In our case, CustomerID. Every Customer ges a branded website with there logos and webpage etc.. To Avoid having 1 ASP.Net application running for each client I am attempting a more...
2
11515
by: Darren.Ratcliffe | last post by:
Hi If I have functionX in my master page, how would I call the function from my .aspx page that has the master page assigned to it? Many thanks Darren
4
1684
by: Ajvan | last post by:
Hi everybody, I have one problem, and I hope some of you guys can help me with this. I`m working in C# (Visual Studio 2005)...writing simple web site . I place grid on Default.aspx and put one textbox in it. On the other side, on Default.aspx.cs page I write simple method which dynamicly generate Radio Button on page..(code bellow): protected void ActivateScript() { Response.Write("<tr><td> <input type=\"radio\" value=\"1\"...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10341
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.