Solved

direct cast an asp button inisde a listview layout template

Posted on 2010-08-27
10
637 Views
Last Modified: 2013-11-27

I am trying access a button in a list view layout template none of this will work , any suggestion?


Protected Sub ListView1_LayoutCreated(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.LayoutCreated

        'Dim mybtnPrint As Button = CType(ListView1.FindControl("btnPrint1"), Button)
        'Dim myButtonPrint As Literal = DirectCast(ListView1.FindControl("btnPrint1"), Literal)
        'Dim rickButton As Button = DirectCast(ListView1.Controls(1).FindControl("btnPrint1"), Button)
        ' mybtnPrint.Attributes.Add("Onclick", "getPrint('print_area');")

        'Dim dataview As ListViewDataItem = TryCast(ListViewDataItem.DataItem, ListViewDataItem)
    End Sub

Open in new window

0
Comment
Question by:TonyReba
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 9

Expert Comment

by:puru1981
ID: 33542114
can you share the aspx of the page?

may be it is htmlbutton which you are trying to convert into Button
0
 
LVL 9

Author Comment

by:TonyReba
ID: 33542137
no, is actually an asp button inside a Listview asp.net 3.5 control



<asp:Button ID="btnPrint1" runat="server" Text="Print Selected Providers" onClientclick="javascript:CallPrint('form1')" />

Open in new window

0
 
LVL 9

Expert Comment

by:puru1981
ID: 33542253
is it within the itemtemplate and alternateitemtemplate of the listview?
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 9

Author Comment

by:TonyReba
ID: 33542281
is on the layoutemplate of the listview
0
 
LVL 9

Expert Comment

by:puru1981
ID: 33542495
in the post below table tr and td which are container for the control is runat server and it is working fine for them. can you try this.

http://forums.asp.net/t/1298231.aspx
0
 
LVL 9

Author Comment

by:TonyReba
ID: 33542585
I tried that already but mine is a Button not a Link Button and VS2010 gives me an error!!
0
 
LVL 9

Expert Comment

by:puru1981
ID: 33542844
it should work actually. what is the error you are getting?
0
 
LVL 9

Author Comment

by:TonyReba
ID: 33542862
'Button' is ambiguous , imported from the namespaces or types 'System.Windows.Forms,System.Web.UI.Controls'.
0
 
LVL 9

Accepted Solution

by:
puru1981 earned 500 total points
ID: 33542909
ok then try this

Dim mybtnPrint As System.Web.UI.Controls.Button = CType(ListView1.FindControl("btnPrint1"), System.Web.UI.Controls.Button)

or remove the System.Windows.Forms from the Import statement. it will work.
0
 
LVL 9

Author Closing Comment

by:TonyReba
ID: 33543062
thankyou that made the trick
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question