472,961 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Is possible to call asp.net(c#) function in HTML.....


This is inbaraj from India. I want to know is it possible to run C# functions in HTML. Plz help me.....

If yes let me know the sample codeing....

Thanks in advance...

with regards
Job Seeker
Jun 1 '07 #1
2 4435
4,871 Expert 4TB
The short answer is no, html being client side. What are you trying to do?
Jun 1 '07 #2
You should be able to. I've done it with VB so you should be able to do it in C#. Here's an example:

In my html I have:
<div id="Hello" onmouseover="<%# (GetMouseOverJavascriptFn()) %>" onmouseout="<%# (GetMouseOutJavascriptFn()) %>" runat="server">

In my code behind I have:
Protected Function GetMouseOverJavascriptFn() As String

return = "document.getElementById('elemId').style.visibilit y='visible'"

End Function

Protected Function GetMouseOutJavascriptFn() As String

return = "document.getElementById('elemId').style.visibilit y='hidden'"

End Function

This is the only context in which I've done it. So the key is you put your function in <%# functionName %>
However, the thing to remember is that VB/C# are server-side so you cannot call them as you would a JavaScript function. The functions in the example above get run the first time the page is generated. Once the page is running on the client machine, the only way you can call VB/C# functions is through a postback to the server.

Jun 1 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

by: svend | last post by:
I'm messing with some code here... Lets say I have this array: a1 = ; And I apply slice(0) on it, to create a copy: a2 = a1.slice(0); But this isn't a true copy. If I go a1 = 42, and then...
by: Hiroshi Ochi | last post by:
Hello, Is it possible to initialize javascript function parameters (using MSIE 6.0 and above)? According to the link below, it seems possible to do this. ...
by: Newbie | last post by:
Is it possible to set up an event handler or something else so that when *any* link on the page is clicked it 'fires-up', executes some JS and then continues to process the link that was clicked?...
by: JoeK | last post by:
Hey all, I am automating a web page from Visual Foxpro. I can control all the textboxes, radio buttons, and command buttons using syntax such as: ...
by: sumGirl | last post by:
Is it possible to use a hyperlink to call a vbs sub? I have seen folks using javascript to do this, but I cannot make it work with vbs and I need to. Please no "you should use javascript"...
by: John | last post by:
Last year, I remember finding a web page describing how to pass the name of a file to another web page, and have that web page load that image file. Now, I can't find my record of that (it was...
by: Alison Givens | last post by:
....... that nobody knows the answer. I can't imagine that I am the only one that uses parameters in CR. So, my question again: I have the following problem. (VB.NET 2003 with CR) I have a...
by: dbaplusplus | last post by:
I worked on web development using java script many many years, so I am now a newbie to javascript. I have a single html page, which is generated dynamically using some programming language. Web...
by: Daz | last post by:
Hi everyone. Sorry for the confusing subject, I couldn't think how best to word it. What I would like to know, is if there is an equivilant to this code, in using JSON. <script...
by: Simon | last post by:
I heard that we could do that by using AJAX. Could anybody share how to do it? Thanks.
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.