•
•
•
•
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
![]() |
•
•
Join Date: Jul 2005
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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
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:
The javascript:
Your server code:
All code untested and subject to revision/debugging!
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 SubAll code untested and subject to revision/debugging!
•
•
Join Date: Jul 2005
Location: Dallas, TX
Posts: 481
Reputation:
Rep Power: 4
Solved Threads: 19
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
•
•
Join Date: Feb 2005
Location: Los Angeles, CA
Posts: 86
Reputation:
Rep Power: 4
Solved Threads: 2
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
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
Ex-designz.net
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
- How to link Buttons in C++.NET? (C++)
- login Access Level (VB.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: need to know wich language to use!
- Next Thread: pascal write problem



Linear Mode