473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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(DataBinder.Eval(Container.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*******@nospam.com
Nov 18 '05 #1
2 3020
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*******@nospam.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.public.dotnet.framework.aspnet
NNTP-Posting-Host: adsl-67-65-189-44.dsl.hstntx.swbell.net 67.65.189.44
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:214097
X-Tomcat-NG: microsoft.public.dotnet.framework.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(DataBinder.Eval(Container.DataItem, "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*******@nospam.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.asp

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.public.dotnet.framework.aspnet
Message-ID: <y0**************@cpmsftngxa06.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Lines: 51
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:214111
NNTP-Posting-Host: tomcatimport2.phx.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******@online.microsoft.com

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

--------------------
From: "moondaddy" <mo*******@nospam.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.public.dotnet.framework.aspnet
NNTP-Posting-Host: adsl-67-65-189-44.dsl.hstntx.swbell.net 67.65.189.44
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:214097
X-Tomcat-NG: microsoft.public.dotnet.framework.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(DataBinder.Eval(Container.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*******@nospam.com



Nov 18 '05 #3

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

Similar topics

15
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...
1
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...
0
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...
8
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...
6
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>"...
5
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...
4
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...
2
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
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.