Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Pass Variable to another function (http://www.velocityreviews.com/forums/t111585-pass-variable-to-another-function.html)

manmit.walia@gmail.com 10-13-2005 07:20 PM

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


bcutting@gmail.com 10-13-2005 08:28 PM

Re: Pass Variable to another function
 
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


Dave Hagerich 10-13-2005 08:58 PM

Re: Pass Variable to another function
 
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"];

<bcutting@gmail.com> wrote in message
news:1129235285.953333.183460@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
>




manmit.walia@gmail.com 10-14-2005 12:00 AM

Re: Pass Variable to another function
 
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



All times are GMT. The time now is 05:22 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.