Click here to Skip to main content
11,578,524 members (58,992 online)
Rate this: bad
Please Sign up or sign in to vote.
I have the following code which generates a list of linkbuttons:

public void getSocialStories()
        string user = getSelectedUser();
        List<SocialStory> stories = new List<SocialStory>();
        stories = functions.getSocialStories(user);
        foreach (SocialStory story in stories)
            LinkButton lb = new LinkButton();
            lb.Text = story.Social_story_name;
            ph.Controls.Add(new LiteralControl("<br />"));

And I have a empty asp panelholder:

<asp:PlaceHolder runat="server" ID="ph"></asp:PlaceHolder>

It gets filled with the linkbuttons, which are a result from a mssql database.

I want when a linkbutton is clicked to call a c# function. This function should take a parameter the social_story_id. How can I do that ?

I think one of the ways is using Ajax, but I don't know how to do it. Are there other ways and if not how to do it with ajax?
Posted 17-Dec-12 3:04am
RobBranaghan at 17-Dec-12 9:24am
Can you set the tag of the literal control?
Member 9635907 at 17-Dec-12 9:28am
what do you mean by that ? I am still learning and that's why I am asking such questions.
RobBranaghan at 17-Dec-12 9:39am
Sorry miss reading your post.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I think that you could set the post back url of the LinkButton to pass the ID to the relevant page.

Something about query strings[^]

Something about calling functions from linkbutton...[^]

Hope these links help you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 17 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100