473,394 Members | 1,722 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,394 software developers and data experts.

asp.net Calling a server side function from client side

1
I dynamically create buttons on the fly based on how many objects are in the database, but because of this they can only be html buttons <asp: does not work. Now i need to run a function in my codebehind file any ideas how to do this?

Atm i have:
<input type="submit\" name="GanttButton" value="Button" runat="Server" onclick="Select_Node" id="GanttButton" />

public void Select_Node(object sender, CommandEventArgs e)
{
....
}

but this does not seem to ever fire :S
do i need to create a javascript function on client side which then calls the function on the server?
Apr 12 '07 #1
1 1083
Plater
7,872 Expert 4TB
You need to create the button as controls. Writing "<asp" to the response stream does not send it to the pre-processor or anything.

Lets say you have a <div> (that would be <asp: pannel>) with something like this in your aspx file:
<asp: Pannel runat="server" ID="pnButtonsGoHere">
</asp: Pannel>

now in your code, where you create the buttons you would have something like this:

Button mybt;
for (int i = 0; i < NumButtons; i++)
{
mybt = new Button();
mybt.Tex = "The Displayed Text";
mybt.ID = "bt" + i.ToString();
mybt.Click += new EventHandler(MyButtonHandler);
pnButtonsGoHere.Controls.Add(mybt);
}

Now you will notice I used the same eventhandler for every button. You will need to create that function and inside do like a SWITCH statement on the ID or Text fields. Give that a try.

PS: All the like CSS/STYLE properties can be set for all those buttons, just play around with the members of the control
Apr 12 '07 #2

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

Similar topics

10
by: R.G. Vervoort | last post by:
I am using a javafunction (onclick in select) in which i am calling a function in php (thats why i send this to both php and javascript newsgroups). in the onclick i call the function...
2
by: Øyvind Isaksen | last post by:
Hi! I have made a function calles "send()". When I click a button, I want the function to be prosessed. This is the code that I have made, but it dont work: <%function send()
9
by: Kathryn | last post by:
Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve is this - - Page loads up and some server side...
12
by: HarveyB | last post by:
I would like to generate non-modal popup windows from ASP.Net code-behind. I have tried using Client Side scripting like "function Test(){ window.open('test.htm',_blank,...
1
by: Benny | last post by:
Hello all, How can i call a server side function (in .aspx.cs) from a client side (in .aspx) using javascript? thanks, benny *** Sent via Developersdex http://www.developersdex.com ***
3
by: David P. Donahue | last post by:
This is a 2-part question: 1) I have a web form with multiple ImageButtons on it. I'd like them all to do the same thing. Basically, in english-code, the function would be as follows: Set...
5
by: Krishna | last post by:
Hi all, Can i call my javascript functions from the web controls.Any appropriate site which will be tell more on this will be helpfull. Regards.., Krishna
1
by: J. Marcelo Barbieri | last post by:
a.. How to write server script to call a client side function written in JavaScript? a.. When using Validation controls, it uses a file named WebUIValidation.js. This file is sent to the client...
4
by: Zeebra3 | last post by:
Here goes: I have a web form with several asp:dropdownlists, with which, when selection is changed I want to fire an event defined in some clientside js. The content of the clientside code is...
3
by: ScooterMX | last post by:
I just have a function that does some sql stuff. When I run this I get an object expected error on the <input type="button"... line Does anyone have a suggestion? This is written for IE only -...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.