Click here to Skip to main content
Sign Up to vote bad
good
See more: ASP.NET
I want to fetch data on modalpopup by clicking linkbutton which is inside repeater control..
Posted 23 Jan '13 - 19:24

Comments
shabari7 - 24 Jan '13 - 2:11
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
 

 
//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
 
//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  
     }
}
  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 611
1 Maciej Los 265
2 Slacker007 240
3 CPallini 235
4 OriginalGriff 210
0 Sergey Alexandrovich Kryukov 9,118
1 OriginalGriff 7,134
2 CPallini 3,803
3 Rohan Leuva 3,135
4 Maciej Los 2,558


Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 24 Jan 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid