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

Pass Variable to another function

Hi,
I have a small question...Is there a way to do a postback to the same
page and pass a value to a function OnClick?

Example:

void GetCityName(string c)
{
string city = c;
}

Now I want to call this function by Doing a PostBack with a
asp:LinkButton.

So, here is the asp:LinkButton code.
<asp:LinkButton ID="mob" runat="server" Text="MOB"
OnClick="GetCityName('MOB')"></asp:LinkButton>

Can this be done?

Thanks

Nov 19 '05 #1
3 1218
A Onclick serverside event must conform to the delegate signature of
the CommandEventHandler. You could store the value in a hidden html
input using javascript, then in your server event handler retrieve the
value by using Request.Form.GetValues.

Endo

Nov 19 '05 #2
Or store the value in a session variable.
i.e.
Session["city"] = city;

then have the event handler grab it
i.e.
city = (string)Session["city"];

<bc******@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
A Onclick serverside event must conform to the delegate signature of
the CommandEventHandler. You could store the value in a hidden html
input using javascript, then in your server event handler retrieve the
value by using Request.Form.GetValues.

Endo

Nov 19 '05 #3
I am total lost...
Does anyone have an example...

What I have is a map of Alabama. So now if I show Mobile, Montgomery on
the map...
and make each city as a LinkButton.

What I am doing is when the user clicks on (MOB) which is Mobile....I
have a query string that goes to a SQL Server and find data where the
city = 'mob'. I want to create a generic function that does this. So
everytime Ijust click a city all that I have to do is call the function
name and pass the city code.

Thanks

Nov 19 '05 #4

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

Similar topics

6
by: Randell D. | last post by:
Folks, I've asked this before but never got any response but its important and I thought I'd pitch it again (hopefully a bit clearer)... One can pass data from one function to another either...
10
by: Doug Jordan | last post by:
I am fairly new to Python. This should be an easy answer but I cannot get this to work. The code is listed below. I know how to do this in C, Fortran, and VB but it doesn't seem to work the same...
110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
7
by: Xiaoshen Li | last post by:
Dear All, I thought I understood using pointer variables as function parameters. But I failed to understand why it is needed pass-by-reference of a pointer variable. To me, pointer variable...
5
by: David++ | last post by:
Hi folks, I would be interested to hear peoples views on whether or not 'pass by reference' is allowed when using a Web Service method. The thing that troubles me about pass-by-reference into...
28
by: Bill | last post by:
Hello All, I am trying to pass a struct to a function. How would that best be accomplished? Thanks, Bill
10
arunmib
by: arunmib | last post by:
hi all, I just got this freaky kind of doubt....I have the following piece of code, int main() { int Val= 10, *ptr; ptr = &Val; TestFn(&Val);
11
by: venkatagmail | last post by:
I have problem understanding pass by value and pass by reference and want to how how they are or appear in the memory: I had to get my basics right again. I create an array and try all possible...
12
by: Bryan Parkoff | last post by:
I write my large project in C++ source code. My C++ source code contains approximate four thousand small functions. Most of them are inline. I define variables and functions in the global scope....
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.