User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 391,998 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,201 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 5766 | Replies: 4
Reply
Join Date: Jul 2005
Posts: 3
Reputation: iloveorangesoda is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
iloveorangesoda iloveorangesoda is offline Offline
Newbie Poster

disable pager link buttons

  #1  
Aug 24th, 2005
Hi I am trying to disable my pager linkbuttons during postback to prevent multiple clicking as this causes the application to fall over. I have tried to use the following code but it is not working. Anyone any ideas?


 
Private Sub DataGrid_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid.ItemCreated

            If (e.Item.ItemType = ListItemType.Pager) Then
                

                e.Item.Attributes.Add("onclick", "this.disabled=true;")

                
            End If
            


            



        End Sub
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: disable pager link buttons

  #2  
Aug 24th, 2005
That's because "disabled" isn't a client-side property of the rendered control. It's a server-side property that makes no sense in the browser.

There isn't a way to "disable" a hyperlink, per se. What you can do is define a hyperlink CSS class that "looks" disabled, and then you can change the "href" property to navigate back to the top of the page, rather than submitting the form or going off somewhere else. Server-side, you'll also have to turn off the auto-postback of that element.

So, here's some CSS and JavaScript to make the hyperlink appear disabled, and navigate to page top:

The CSS:
.disabledHyperLink
{
  color: #333;
  text-decoration : none;
  cursor: default;
}

The javascript:
function disableHyperlink(linkID)
{
  var hlink = document.getElementById(linkID);
  if(!hlink)
    return;
    
  hlink.href = "#";
  hlink.className = "disabledHyperLink";
}


Your server code:
Private Sub DataGrid_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid.ItemCreated
            If (e.Item.ItemType = ListItemType.Pager) Then
                e.Item.Attributes.Add("onclick", "disableHyperlink(this.ID);")
                e.Item.autopostback = false
            End If
        End Sub

All code untested and subject to revision/debugging!
Reply With Quote  
Join Date: Jul 2005
Location: Dallas, TX
Posts: 481
Reputation: campkev is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: disable pager link buttons

  #3  
Sep 8th, 2005
what about doing this

 
Private Sub DataGrid_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid.ItemCreated

            If (e.Item.ItemType = ListItemType.Pager) Then
                

                e.Item.Enabled=false;
                
            End If
            


            



        End Sub
Reply With Quote  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: disable pager link buttons

  #4  
Sep 8th, 2005
Because that will cause the control not to be rendered at all. That wasn't the question. It was how to make it appear and act disabled. This makes sense... users understand a "disabled" control. They don't always understand a control that mysteriously vanishes!
Reply With Quote  
Join Date: Feb 2005
Location: Los Angeles, CA
Posts: 86
Reputation: dexterz is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 2
dexterz dexterz is offline Offline
Junior Poster in Training

Re: disable pager link buttons

  #5  
Sep 11th, 2005
Hello orange soda,

I don't get the idea of disabling the pager button to prevent mutiple click on the page postback. The purpose of the pager is to be able the users to move from page to page. There must be something wrong in your code that fire an event during the page postback.

Check out the datagrid I created.
http://www.myasp-net.com/directory/adminlogin.aspx

You can download this application for free at:
http://www.myasp-net.com

Dexter zafra
Dexter Zaf
Ex-designz.net
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 10:04 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC