I'm trying to make it so that a LinkButton doesn't get greyed out in IE when Enabled="False". Disabling the postback like they suggest here and here works but doesn't stop the cursor and text colour from changing when you hover over it as if it were a button, like Enabled="False" does.
<asp:LinkButton ID="LinkBut1" runat="server" CssClass="Tag" Enabled="False"
OnClick="LB_Click" Text="Add" />
(Using .NET 4 and C#)
Thanks.
Have you considered extending the LinkButton class, overwriting the Rend method and doing something like:
protected override void Render(HtmlTextWriter writer)
{
if (!this.enabled)
...write an html span that looks like a link or something ...
else
base.Render(writer);
}
Related
I have been trying to change the text of the back button in Xamarin.Forms without luck.
I tried already this code with no luck:
NavigationPage.SetBackButtonTitle(this, "");
I'm using a MasterDetailPage.
I tried to add the code into the constructor of the XAML cs file.
Libraries used: PRISM 6.2.0, Xamarin Forms 2.3.1.114
Any suggestion or idea?
Thanks in advance
Due to the topic:
One of the things that is a little bit unintuitive about this API is that you are setting the title for the back button that shows up when this page is the one that you are going back to. For example, you are trying to set the title to "Home". That means you should be calling this method on the Page that represents the "home" page, not the page that is visible when the back button that says "Home" is showing.
So, if you are navigating from Page1 to Page2, you should set NavigationPage.SetBackButtonTitle(this, "") in constructor of Page1 and on Page2 you will see the empty title of back button.
You have to set the Backbutton title of your previous page as string.Empty. By default it's the title of the previous page on the navigation stack that is shown as the back button text.
Also Android does not support this property.
You can also do it from the Code Behind of the current xaml page
public TodoPage()
{
InitializeComponent();
NavigationPage.SetBackButtonTitle(this, "Back");
}
NB: It has to be done on the previous page you want to set.
e.g. Page A has to have the code if you want Page B to show "Back" title.
Belated answer but maybe someone will find this useful in the future… Anyhow, if you wish to get rid of the back button title from XAML, you can either add NavigationPage.BackButtonTitle="" for any ContentPage that should have the title removed or you can define new ContentPage style in your App.xaml file like this:
<Style x:Key="ContentPageStyle" TargetType="ContentPage">
<Setter Property="BackgroundColor" Value="White" /><!-- just an example of other things that can be in here -->
<Setter Property="NavigationPage.BackButtonTitle" Value="" />
</Style>
I was, however, unable to turn this into an implicit global style that would get applied automatically without the need to specify Style="{StaticResource ContentPageStyle}" for each ContentPage – I'm not sure why that one doesn't work.
You can set the attribute NavigationPage.BackButtonTitle on ContentPage
For example:
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:T3R"
mc:Ignorable="d"
Title="Title of Page"
NavigationPage.BackButtonTitle="Cancel"
x:Class="T3R.MainPage">
Remember the following:
I understand this only works on iOS
For any given page, the back button title is set by the page that presents it. This way, the button label can vary with respect to the page that precedes it on the navigation stack (of which there can be many).
You can set your back button text in XAML as follows (before ContentPage.Content):
<NavigationPage.TitleView>
<Label Text="{Binding PageTitle}" HorizontalOptions="Center"/>
</NavigationPage.TitleView>
I think I'm getting blind....! What's wrong with the following code?
With Visual Studio 2013 "searchBox" doesn't return a value but with VS 2008 it works well.
CODE BEHIND
Partial Class _Default
Inherits Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Write(Request.Form("searchBox"))
End Sub
End Class
HTML PAGE
<%# Page validateRequest="false" Title="Home Page" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<asp:TextBox ID="SearchBox" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Search" />
</asp:Content>
It can't works with VS2008 either. As it is a server control, the actual client id of the control won't be searchbox but a concatenation of all parents ids of the control. Something like ctl00_somePanel_someContainer_SearchBox.
Request.Form will contain raw html form control's values, including the value generated by the client side version of the SearchBox, with its actual generated id.
To solve your issue, you can:
read the SearchBox.Text property instead of reading the Form object (probably the best option)
replace the server control by a pure client one (<input type='textbox' id='SearchBox'/>
fix the control ID using CliendIDMode, but I believe this is a poor option
The easiest would be when you want to use Request.Form("searchBox") is to set it as follows:
<asp:TextBox ID="SearchBox" clientmode="Static" runat="server"></asp:TextBox>
This forces the object to be created with the name "SearchBox" that you set it too, not "ctl00_somePanel_someContainer_SearchBox" that is a name that only it knows how to interpret.
It is not the best way to access the object, but this will get you going the way you are doing it.
I have an ASP.Net RadioButtonList control with AutoPostBack set to true and a server side handler for the SelectedIndexChanged event.
<asp:RadioButtonList runat="server" ID="btnAcceptReject" RepeatDirection="Horizontal" CssClass="checkboxlist borderless" ValidationGroup="data" AutoPostBack="true" OnSelectedIndexChanged="radioButtonList_SelectedIndexChanged">
<asp:ListItem Text="The edition is hereby validated for conformity to standards" Value="0" Selected="True"></asp:ListItem>
<asp:ListItem Text="The edition does not meet standards and still has to be reviewed" Value="1"></asp:ListItem>
</asp:RadioButtonList>
I am using a RadAjaxManager, a telerik control, to handle ajax postbacks
<telerik:RadAjaxManagerProxy runat="server" ID="RadAjaxManagerPRoxy1">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="btnAcceptReject">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="pnlControls" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
pnlControl is a panel on the page containing controls that will be enabled/disabled depending on which radio button was checked.
The above always performs a full postback of the page.
how can i make it perform an ajax partial postback?
Could it be a result of you using RadAjaxManagerProxy instead of RadAjaxManager?
RadAjaxManagerProxy expects that there is a RadAjaxManager declared elsewhere within a Master Page etc.
If that fails then I suggest to alter the pnlControl to become a RadAjaxPanel and then remove the RadAjaxManagerProxy declaration as the RadAjaxPanel will do all the work for you.
Good luck!
In reply to your comments, I would now suggest to do the following within the referencing ASPX page (if that is possible under your scenario):
Add a RadAjaxManagerProxy to the client-side
Within the code-behind add a new Sub to be called during Page_Load (outside the postback check)
Within the Sub:
Dim panel As Panel = CType(myUserControl.FindControl("pnlControls"),Panel)
Dim radio As RadioButtonList = CType(myUserControl.FindControl("btnAcceptReject"), RadioButtonList)
RadAjaxManagerProxy1.AjaxSettings.AddAjaxSetting(radio, panel, Nothing)
*Nothing - Optionally a RadAjaxLoadingPanelID if you have one declared on the .ASPX page
Hope it helps!
I have the following function that updates the UpdatePanel content by adding/loading an ascx custom usercontrol in the placeholder that is in default.aspx:
protected void NavigationTab_Click(string ascxpath)
{
Control ctrl = LoadControl(ascxpath);
//cphmaincontent is my asp ContenPlaceHoderId in masterpage
PlaceHolder phmaincontent = (PlaceHolder)cphmaincontent.FindControl("phmaincontent");
phmaincontent.Controls.Clear();
phmaincontent.Controls.Add(ctrl);
upmaincontent.Update();
}
Masterpage UpdatePanel:
<asp:UpdatePanel ID="upmaincontent" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lbmsg" runat="server" Text=""></asp:Label>
<asp:ContentPlaceHolder ID="cphmaincontent" runat="server">
</asp:ContentPlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
I am calling NavigationTab_Click from my navigation control that is another custom ascx control, my ctrl Control object that is loading dynamically on each has button and label when I click the button it simply reassigns some text to the label.
and I have this following code on my masterpage just to get the ascx control path:
protected override void OnInit(EventArgs e)
{
//raising an event to set ascx path
mainmenu.NavigatePath += new usercontrols.mainmenu.NavigationHandler(NavigationTab_Click);
base.OnInit(e);
}
so far everything works good, after loading my ctrl object by calling NavigationTab_Click function I see my ctrl in the placeholder and has the button and the label but the issue is this if I click this button it should reassign the label to some text but instead the whole ctrl control content disappears, please help.
When you're adding controls dynamically you must ensure that it gets recreated on every postback. You also have to ensure that you assign the same ID as before, otherwise events will not be triggered correctly and values cannot be reloaded from ViewState. This must be done it Page_Load at the latest(better in Page_Init).
That's the reason why you should avoid dynamical controls whenever possible.
So you can add controls in event-handlers like you've done. But they must be recreated on the next Postback. So you need to store somewhere what(f.e. IDs) or how many controls are already created. That can be done for example in ViewState or Session. Then you can assign appropriate IDs to the controls(for example with the index or ID suffixed).
Here are some additional informations on this subject:
View State and Dynamically Added Controls *
ASP.NET Page Life Cycle Overview
I have a RadGrid in a RadWindow set to Modal.
I'm seeing two issues.
The first and most critical ONLY HAPPENS IN IE7 and NOT in FIREFOX is that the Filter Menus of the RadGrid do not display when clicked. Instead a box the size of the menus is opened through which I can see the parent page.
The second and probably related HAPPENS IN BOTH IE AND FIREFOX is that when I drag the RadWindow the content of the RadWindow disappears and is replaced by the same transparency to the parent page.
Any help you could offer would be great. I've spent all day hunting and pecking through CSS trying to find it.
Grid and window declarations follow.
<telerik:RadWindowManager
OnClientClose="OnViewerClose"
Behaviors="Close, Move, Resize,Maximize"
ID="RadWindowManager"
DestroyOnClose="true"
Opacity="99"
runat="server">
<Windows>
<telerik:RadWindow
ID="AssociateUserWindow"
VisibleOnPageLoad="false"
Width="600"
Height="400"
runat="server"
Overlay="true"
KeepInScreenBounds="true"
Modal="true"
Skin="WebBlue">
</telerik:RadWindow>
</Windows>
</telerik:RadWindowManager>
<telerik:RadGrid
ID="rgUsers"
runat="server"
AllowPaging="true"
AllowSorting="true"
AutoGenerateColumns="false"
CellPadding="1"
CellSpacing="2"
GridLines="Vertical"
Skin="WebBlue"
Width="100%"
OnItemDataBound="rgUsers_ItemDataBound"
OnNeedDataSource="rgUsers_NeedDataSource"
PageSize="5"
>
<PagerStyle Mode="NumericPages"></PagerStyle>
<MasterTableView DataKeyNames="UserId" AllowMultiColumnSorting="True" AllowFilteringByColumn="true" HierarchyDefaultExpanded="true">
<Columns>...ommitted...</Columns>
</MasterTableView>
</telerik:RadGrid>
Are you able to extract a runnable sample that displays the issue? If you can I think the best thing to do here, since the markup that you posted looks completely fine, is to submit this in a support ticket over at Telerik. Their support guys will probably be the best to figure out what the issue might be.
Nevermind. I've found the issue... that opacity setting was the culprit. Removing it from the radwindow manager fixed it.