Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to fetch data on modalpopup by clicking linkbutton which is inside repeater control..
Posted
Comments
[no name] 24-Jan-13 2:11am    
just add onclient click event to link button and pass necessary arguments to process the request

1 solution

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



VB
//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
        Try
            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
            Throw
        End Try

    End Sub




ASPX Page will have the code to open the modal PopUp

JavaScript
//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  
     }
}
 
Share this answer
 
v2

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