Click here to Skip to main content
12,557,291 members (48,856 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET
I want to fetch data on modalpopup by clicking linkbutton which is inside repeater control..
Posted 23-Jan-13 19:24pm
shabari7 24-Jan-13 2:11am
just add onclient click event to link button and pass necessary arguments to process the request

1 solution

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

Solution 1

there are two ways...if you have few values to show in PopUp you can simple bind them at runtime to the link button.

If you have too many values you will have to create an Object of the class. So if you are showing user information in the popup create an object of the User Class. serialize it and bind to the click event of link button

//Global variable which will serailze. 
ReadOnly _js As New JavaScriptSerializer

Protected Sub rptSearchResults_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptSearchResults.ItemDataBound
            If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
                Dim drv As DataRowView = TryCast(e.Item.DataItem, DataRowView)
                 userObj = New Users
        userObj.UserId = DataBinder.Eval(e.Row.DataItem, "userId")
        userObj.UserName = DataBinder.Eval(e.Row.DataItem, "userNm")
''You can now add all properties which you want to show.
                Dim lnkBtn As HtmlAnchor = TryCast(e.Item.FindControl("lnkBtn"), HtmlAnchor)
                Dim btnUser As HtmlInputButton = TryCast(e.Item.FindControl("btnNewBCD"), HtmlInputButton)
                If Not (lnkBtn Is Nothing) Then
                 lnkBtn.Attributes.Add("href", "javascript:OpenPopUp('" & drv("acct_id").ToString() & "','" & drv("acct_nm").ToString() & "');")
                End If
               If Not (lnkBtn Is Nothing) Then
                 btnUser.Attributes.Add("href", "javascript:OpenPopUp('" & _js.Serialize(userObj)& "');")
                End If
        Catch ex As Exception
        End Try
    End Sub

ASPX Page will have the code to open the modal PopUp

//if passing individual values
fucntion OpenPopUp(a,b){
   //Open Modal PopUp using a and b
//if passing through seriliazed object
function OpenPopUp(a)
    if (typeof a !=="undefined")
       //assuming lbl is the javascript object for the label containing name text
       lbl.val(a.UserId) //remeber the property names are case sensitive and will beeactly the same as your class properties  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161026.1 | Last Updated 24 Jan 2013
Copyright © CodeProject, 1999-2016
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