Click here to Skip to main content
11,705,208 members (42,158 online)
Rate this: bad
good
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
Comments
shabari7 at 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
good
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
        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  
v2

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 550
1 OriginalGriff 244
2 ppolymorphe 126
3 CPallini 82
4 F-ES Sitecore 70
0 OriginalGriff 8,988
1 Sergey Alexandrovich Kryukov 8,272
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,606


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