Click here to Skip to main content
Sign Up to vote bad
good
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 />"));
            ph.Controls.Add(lb);
        }
    }
 
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:04

Comments
RobBranaghan - 17 Dec '12 - 9:24
Can you set the tag of the literal control?
Member 9635907 - 17 Dec '12 - 9:28
what do you mean by that ? I am still learning and that's why I am asking such questions.
RobBranaghan - 17 Dec '12 - 9:39
Sorry miss reading your post.

1 solution

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
http://www.w3schools.com/ASP/coll_querystring.asp[^]
 
Something about calling functions from linkbutton...
 
http://www.w3schools.com/aspnet/prop_webcontrol_linkbutton_onclientclick.asp[^]
 
Hope these links help you!
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 8,123
1 OriginalGriff 6,040
2 CPallini 3,432
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 17 Dec 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid