Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Pass Variable to another function

Reply
Thread Tools

Pass Variable to another function

 
 
manmit.walia@gmail.com
Guest
Posts: n/a
 
      10-13-2005
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

 
Reply With Quote
 
 
 
 
bcutting@gmail.com
Guest
Posts: n/a
 
      10-13-2005
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

 
Reply With Quote
 
 
 
 
Dave Hagerich
Guest
Posts: n/a
 
      10-13-2005
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"];

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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
>



 
Reply With Quote
 
manmit.walia@gmail.com
Guest
Posts: n/a
 
      10-14-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to pass C++ object to another C++ function via Python function grbgooglefan Python 9 05-09-2008 01:34 PM
Pass a local variable to another function madmikeproductions@gmail.com Javascript 5 01-29-2008 02:55 PM
how to pass a function as an argument to another function laredotornado@zipmail.com Javascript 8 02-01-2007 09:58 AM
Trying to pass values of variables from a redefined function into another function deanfamily C++ 4 10-23-2005 11:36 PM
How to pass variable argument list to another function w/ variable argument list? Ben Kial C Programming 1 11-15-2004 01:51 AM



Advertisments