Disable only the link part of a ASP.Net LinkButton - c#

I have a ASP.Net LinkButton in a Repeater. In some conditions on some rows i'm trying to disable the link of the button so that it acts more like a Label, where other rows will be a link that fires off the ItemCommand event.
What is a good solution for this? I'm trying to avoid having two separate control on the page to handle pretty much the same thing.
Anyone have experience with this?

Wire into the ItemDataBound event for the repeater. In each item, find the link button, and then use a method like on this solution to disable the link button on an item by item basis
How to completely disable the link button?

Related

LinkButton Postback In Repeater In Modal

The code is a little big to post here, but hopefully someone can give me some ideas on what to look for.
I've got an ASP.NET Webforms page, containing a Bootstrap Modal dialog box. Inside this modal I have some runat="server" controls, including a Repeater. I have 2 LinkButton controls, one inside the Repeater and one outside, both of which are bound to the same server-side event handler.
The link outside the Repeater works correctly. The one inside still posts-back, but does not fire the event as expected.
Some things I noticed:
My first thought was that the modal was being removed from the
ASP.NET form (as some are prone to do), but if this was true, none
of the controls inside would work.
I tried this using regular Buttons, and it worked correctly. That
means it's something to do with the __doPostBack Javascript that
LinkButtons use.
Any ideas?
If I understand you correctly, are you say that LinkButton in Repeater cause full post-back?
are you try to set ClientIDMode="AutoID" for repeater?
What do you mean "but does not fire the event as expected"

Wiring up a dynamically created LinkButton that is being inserted into a PlaceHolder that is in a ListView Item

I have a ListView that is outputting line items that each have a PlaceHolder object.
Within that PlaceHolder I am outputting any number of LinkButtons.
I am adding a Click event Handler to each Link Button to invoke a code-behind method.
HOWEVER,
The method is not being fired when the link buttons are clicked. I need help determining why this is and how I might be able to fire a method in the code-behind when one of these Link Buttons are clicked.
I have already performed the process of storing the LinkButton controls so that they repopulate the Placeholders after a post back. (They don't disappear when clicked).
All suggestions welcomed! Thanks!
Here is a link for an example of LinkButton to review and verify your code is correct. if not helpful, copy your code to let us help you and solve the problem.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutton(v=vs.110).aspx

Dynamic Page - accessing elements in events

How to create a dynamic page in pageload() event and how to call the values like textbox or radio button on an button click event or in any other events?
Kindly give a small example. Thanks in advance!
You can create create any ASP.NET control dynamically and add them to the Page.
TextBox txtBox = new TextBox();
If you have to access these values in the post-back. Then it is better to create them in Page_Init() than Page_Load(). If you are creating a dynamic element then you have to create them on every post-back.
There are some good articles on these topic. Google them

Gridview, is there an event, how would I determine that it has finished being rendered?

Gridview, is there an event, how would I determine that it has finished being rendered? That's basically it, I want to adjust the height of some other controls on the page and I want to pick up this event.
Sorry I should have been more explicit in stating that this is actually a web page not a winform. In the end I managed to solve the problem by registering a function with the page load which is called after the controls have been drawn and they calling the gridview size and resizing the other controls to fit. It works and that is that.
Thanks.
The GridView inherits from Control so you can use any of the events, I would try PreRender, it seams it will provide you with what you need
To see all the GridView events available to you;
In Design Mode, select the gridview and click F4.
In the properties window there is a 'lighting' tab which lists all gridview events you can attach to.
Assuming you are in winforms, the best place to do it would be after you bind data to your grid, in the DataBindingComplete event.
Managed to solve it, see details above.

Telerik RadGrid nopersistence (viewstate=false), doesn't keep the selectedindex on postback

i'm using a Telerik Radgrid on ASP.Net 3.5 and whenever I postback, the selectedindex is gone. I also used the NeedDataSource event to bind my data, and I do feel it may be related to that. is there a way to use both seamlessly without viewstate?
Hm, that's strange, as this is not the case here:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/needdatasource/defaultcs.aspx
when you change the skin with postback from the dropdown in the top right corner. Also, in case you postback from ajaxified control, make sure the grid is updated on postback as well.
Dick
Regular postback should not fire NeedDataSource and rebind grid. If you sort, page, filter, etc. the grid, consider this solution.
Dick

Categories

Resources