Click here to Skip to main content
15,887,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have the following code which generates a list of linkbuttons:

C#
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.NET
<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
Comments
Rob Branaghan 17-Dec-12 9:24am    
Can you set the tag of the literal control?
Member 9635907 17-Dec-12 9:28am    
what do you mean by that ? I am still learning and that's why I am asking such questions.
Rob Branaghan 17-Dec-12 9:39am    
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!
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900