I have a RadToolBar (RadToolBar1) placed inside a RadGrid. When I use Tab to focus a RadToolBarButton and press Enter, the server-side event doesn’t fire (e.g., CommandName="InitInsert"). How can I make pressing Enter trigger the button’s server-side event?
I've tried this code, but it was not working.
function pageLoadHandler() { var buttonList = document.querySelectorAll('.RadToolBar .rtbUL .rtbItem'); if (buttonList) { buttonList.forEach((button) => { button.addEventListener("keydown", (e) => { if (e.code === "Enter") { button.click(); } }) }) } } Sys.Application.add_load(pageLoadHandler);
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True" Width="100%"
CssClass="mx " GridLines="None" Skin="Bootstrap" PageSize="12"
OnNeedDataSource="RadGrid1_NeedDataSource" OnItemCommand="RadGrid1_ItemCommand"
OnUpdateCommand="RadGrid1_UpdateCommand" OnInsertCommand="RadGrid1_InsertCommand"
OnItemDataBound="RadGrid1_ItemDataBound" OnDeleteCommand="RadGrid1_DeleteCommand">
<PagerStyle Mode="NumericPages"></PagerStyle>
<MasterTableView Name="MASTER" AutoGenerateColumns="False"
DataKeyNames="aid,utype,uid,is_enabled,project,user_level,plan,salt,valid,mail"
CommandItemDisplay="Top" PageSize="20" TableLayout="Fixed" EditMode="EditForms">
<HeaderStyle BackColor="#D6F2F6" CssClass="mx header" />
<ItemStyle BackColor="beige" CssClass="mx item" />
<AlternatingItemStyle BackColor="white" CssClass="mx" />
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn ButtonType="ImageButton">
<HeaderStyle Width="24"></HeaderStyle>
</ExpandCollapseColumn>
<CommandItemStyle Height="40" BackColor="#45B3D8" Font-Size="1.1em" />
<CommandItemTemplate>
<telerik:RadToolBar RenderMode="Lightweight" ID="RadToolBar1" runat="server"
CssClass="mm-cmd" AutoPostBack="true" BorderStyle="Groove">
<KeyboardNavigationSettings CommandKey="Alt" FocusKey="M" />
<Items>
<telerik:RadToolBarButton Text="新增學校帳號" CheckOnClick="true" AllowSelfUnCheck="true" CommandName="InitInsert"
ImageUrl="~/images/add.png"
Visible='<%# ! (RadGrid1.MasterTableView.IsItemInserted || RadGrid1.EditIndexes.Count > 0 || Session["user_level"].ToString()!="1") %>'>
</telerik:RadToolBarButton>
<telerik:RadToolBarButton Text="放棄編輯" CommandName="CancelAll"
ImageUrl="~/images/cancel_103431.png" CausesValidation="false"
Visible='<%# RadGrid1.MasterTableView.IsItemInserted || RadGrid1.EditIndexes.Count > 0 %>'>
</telerik:RadToolBarButton>
<telerik:RadToolBarButton runat="server" IsSeparator="true" BackColor="#45B3D8"
Width="">
</telerik:RadToolBarButton>
<telerik:RadToolBarButton Text="更新" CommandName="Rebind"
ImageUrl="~/images/refreshdata.png">
</telerik:RadToolBarButton>
<telerik:RadToolBarButton runat="server" IsSeparator="true" BackColor="#45B3D8"
Width="">
</telerik:RadToolBarButton>
</Items>
</telerik:RadToolBar>
</CommandItemTemplate>
<Columns>
<telerik:GridButtonColumn ConfirmText="確定刪除帳號?" ConfirmDialogType="RadWindow" Text="刪除帳號"
UniqueName="DeleteColumn"
ConfirmTitle="刪除帳號" ButtonType="ImageButton" CommandName="Delete" HeaderText="刪除"
ConfirmDialogHeight="200px" ConfirmDialogWidth="320px" HeaderStyle-Width="38"
ImageUrl="~/images/delete16x16.png" />
<%-- <telerik:GridEditCommandColumn UniqueName="EditCommandColumn1" HeaderStyle-Width="38"
ButtonType="ImageButton" EditImageUrl="~/images/edit16x16.png"
InsertImageUrl="~/images/save16x16.png" EditText="編輯這筆資料" HeaderText="編輯"
UpdateImageUrl="~/images/save16x16.png" UpdateText="保存資料" CancelText="放棄編輯"
CancelImageUrl="~/images/cancel16x16.png">
</telerik:GridEditCommandColumn> --%>
<telerik:GridTemplateColumn HeaderText="編輯" UniqueName="EditCol" HeaderStyle-Width="38">
<ItemTemplate>
<asp:ImageButton ID="btnEdit" runat="server"
ImageUrl="~/images/edit16x16.png"
CommandName="Edit"
AlternateText="編輯這筆資料" ToolTip="編輯這筆資料" />
<!-- 這個 Label 會輸出 <label for="btnEdit的clientId"> -->
<asp:Label ID="lblEditFor" runat="server"
AssociatedControlID="btnEdit" CssClass="sr-only"
Text="編輯這筆資料"></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="id" HeaderText="id" SortExpression="id" UniqueName="id"
Display="false" ReadOnly="True">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="uid" HeaderText="帳號"
HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
SortExpression="uid" UniqueName="uid" HeaderStyle-Width="150" ReadOnly="True"
HeaderStyle-Font-Size="0.917em" ItemStyle-Height="22px" ItemStyle-Font-Size="0.917em">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="uname" HeaderText="帳號管理人姓名" SortExpression="uname"
HeaderStyle-Font-Size="0.917em" ItemStyle-Height="22px" ItemStyle-Font-Size="0.917em"
ItemStyle-Font-Names="微軟正黑體" HeaderStyle-Font-Names="微軟正黑體" UniqueName="uname"
HeaderStyle-Width="100px" HeaderStyle-HorizontalAlign="Center"
ItemStyle-HorizontalAlign="Center">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="title" HeaderText="職稱" SortExpression="title"
HeaderStyle-Font-Size="0.917em" ItemStyle-Height="22px" ItemStyle-Font-Size="0.917em"
ItemStyle-Font-Names="微軟正黑體" HeaderStyle-Font-Names="微軟正黑體" UniqueName="unit"
HeaderStyle-Width="160px" HeaderStyle-HorizontalAlign="Center"
ItemStyle-HorizontalAlign="Center">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderStyle-Width="140" HeaderText="帳號權限"
HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<%# Eval("user_level").Equals("1")?"學校管理員":"老師帳號" %>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderStyle-Width="140" HeaderText="帳號狀態"
HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<%# Eval("is_enabled").Equals("1")?"啟用":"停用" %>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderStyle-Width="140" HeaderText="信箱狀態"
HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<%# Eval("mail").ToString().Equals("")?"尚未填寫信箱":(Eval("valid").Equals("Y")?"已驗證":"<a href=\"SendMailCheck\">尚未驗證</a>") %>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<EditFormSettings EditColumn-CancelText="取消" EditColumn-UpdateText="更新"
EditColumn-InsertText="新增" EditColumn-ButtonType="ImageButton" EditFormType="Template">
<EditColumn ButtonType="ImageButton" CancelText="取消" UpdateText="更新" InsertText="新增"
UniqueName="EditCommandColumn">
</EditColumn>
<FormTemplate>
<table class="mx m-table " style="padding: 10px;">
<tr>
<td style="padding: 3px; height: 1.3em; width: 150px">帳號</td>
<td>
<asp:TextBox ID="mUid" runat="server" onkeydown="txtOnKeyPress(this);"
MaxLength="20" Width="120" Placeholder="使用者代碼"
onkeyup="value=value.replace(/[\W]/g,'') "
onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
</asp:TextBox>
<asp:Label runat="server" ID="LB"></asp:Label>
</td>
</tr>
<tr>
<td style="padding: 3px; height: 1.3em; width: 180px">帳號管理人姓名</td>
<td>
<asp:TextBox ID="mUname" runat="server" Text='<%# Bind("uname") %>' autocomplete="off"
MaxLength="20" Width="120"></asp:TextBox>
</td>
</tr>
<asp:Panel runat="server" ID="pass1Panel">
<tr>
<td style="padding: 3px; height: 1.3em; width: 180px">新密碼</td>
<td>
<asp:TextBox ID="mPassword1" TextMode="Password" runat="server" autocomplete="off"
MaxLength="20" Width="120"></asp:TextBox>
</td>
</tr>
<tr>
<td style="padding: 3px; height: 1.3em; width: 180px">確認密碼</td>
<td>
<asp:TextBox ID="mPassword2" TextMode="Password" runat="server" autocomplete="off"
MaxLength="20" Width="120"></asp:TextBox>
</td>
</tr>
</asp:Panel>
<asp:Panel runat="server" ID="pass2Panel">
<tr>
<td style="padding: 3px; height: 1.3em; width: 180px">密碼</td>
<td>
<asp:TextBox ID="mPassword" TextMode="Password" runat="server" autocomplete="off"
MaxLength="20" Width="120"></asp:TextBox>
</td>
</tr>
</asp:Panel>
<tr>
<td style="padding: 3px; height: 3em">職稱</td>
<td>
<asp:TextBox ID="mTitle" runat="server" Text='<%# Bind("title") %>'
MaxLength="100" Width="420"></asp:TextBox>
</td>
</tr>
<tr>
<td style="padding: 3px; height: 3em">備用信箱</td>
<td>
<asp:TextBox ID="mEmail" runat="server" Text='<%# Bind("mail") %>'
MaxLength="100" Width="420"></asp:TextBox>
<asp:RegularExpressionValidator ID="revEmailAddress" runat="server"
SetFocusOnError="true" Display="None" ControlToValidate="mEmail"
resourceKey="revEmailAddress"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ValidationGroup="forgetpassword"></asp:RegularExpressionValidator>
<asp:Literal runat="server" ID="mEmailState" Text=""></asp:Literal>
</td>
</tr>
<tr>
<td style="padding: 3px; height: 1.3em; width: 150px">帳號權限</td>
<td>
<asp:RadioButtonList runat="server" ID="mUser_Level" RepeatColumns="2"
Font-Size="Medium" CssClass="nontable">
<asp:ListItem Value="1" Text="學校管理員"></asp:ListItem>
<asp:ListItem Value="2" Text="老師帳號"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td style="padding: 3px; height: 1.3em; width: 150px">開放計畫權限</td>
<td>
<asp:CheckBoxList RenderMode="Lightweight" ID="listbox" RepeatColumns="6"
Width="100%" runat="server" DataSourceID="SqlDataSource1" DataTextField="name"
DataValueField="plan_code">
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td style="padding: 3px; height: 1.3em; width: 150px">帳號狀態</td>
<td>
<asp:RadioButtonList runat="server" ID="mIs_Enabled" RepeatColumns="2"
Font-Size="Medium" CssClass="nontable">
<asp:ListItem Value="1" Text="啟用"></asp:ListItem>
<asp:ListItem Value="0" Text="停用"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
</table>
<br />
<asp:ValidationSummary ID="mSummary" resourceKey="mSummary" runat="server"
ShowSummary="false" ShowMessageBox="true" ValidationGroup="forgetpassword"
HeaderText="輸入的信箱格式有誤" />
<telerik:RadButton CausesValidation="true" ID="btnUpdate" runat="server"
CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'
Width="120px" Height="36px" Font-Size="1em" ButtonType="LinkButton" ValidationGroup="forgetpassword"
CssClass="customizeIcon"
Text='<%# (Container is GridEditFormInsertItem) ? "保存" : "更新" %>'
UseSubmitBehavior="false">
<Icon PrimaryIconCssClass="rbSave" PrimaryIconTop="8px" PrimaryIconBottom="8px"
PrimaryIconLeft="10"></Icon>
</telerik:RadButton>
<telerik:RadButton ID="btnCancel" CommandName="Cancel" Text="取消" runat="server"
Width="120px" Height="36px" ButtonType="LinkButton" CssClass="customizeIcon"
Font-Size="1em">
<Icon PrimaryIconCssClass="rbCancel" PrimaryIconTop="8px" PrimaryIconBottom="8px"
PrimaryIconLeft="10"></Icon>
</telerik:RadButton>
</FormTemplate>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
My ASP.NET Web Form has a RadTabStrip with 3 different tabs. The first tab has the username and password, the second tab has the permissions, and the third tab has the clients. The username and password have RequiredFieldValidators on them.
I have noticed that whenever I go from one tab to another, the Windows TextBox Control txtPassword's Text field is getting reset, causing the page to not validate whenever tabs 2 or 3 are shown.
I created a hack to fix this:
Protected Sub RadTabStrip1_ClientTabSelecting(sender As Object, e As RadTabStripEventArgs) Handles RadTabStrip1.TabClick
Page.Validate()
If Me.IsValid() Then
If Not String.IsNullOrWhiteSpace(txtPassword.Text) Then
ViewState("password") = txtPassword.Text
End If
Else
If String.IsNullOrWhiteSpace(txtPassword.Text) Then
txtPassword.Text = ViewState("password")
End If
If String.IsNullOrWhiteSpace(txtConfirmPassword.Text) Then
txtConfirmPassword.Text = ViewState("password")
End If
Page.Validate()
If Not IsValid() Then
MultiView1.ActiveViewIndex = 1
RadTabStrip1.SelectedIndex = 0
RadMultiPage1.SelectedIndex = 0
End If
End If
End Sub
I do not like storing their password in the ViewState, but it works.
Almost.
The Submit button is on the bottom of the page, contained within a RadToolBar.
Protected Sub RadToolBar1_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles RadToolBar1.ButtonClick
Dim rb As Telerik.Web.UI.RadToolBarButton = e.Item
Dim clientList As List(Of Client) = ViewState("MyClientList")
If rb.CommandName = "Save" Then
There is a breakpoint on that line of code, but Validation fails before that code is reached.
By this point, my customers are on Tab 3, and they have no way to tell that the txtPassword control has had their input deleted on Tab 1.
Has anyone ever experienced a Windows Control like this password getting cleared whenever the RadTabStrip Index changes?
How do I fix this?
Hi,
How to Get the file path of the file which is uploaded via RadChat ToolBar in ClientSide. I tried with this code and it gives me the only file name.
<telerik:RadChat runat="server" ID="RadChat1" Skin="Default" RenderMode="Lightweight">
<ClientEvents OnToolClick="OnToolClick" OnLoad="onLoad"/>
<ToolbarSettings Toggleable="true" Animation="true">
<AnimationSettings>
<ExpandSettings Duration="500" Effects="expandVertical fadeIn" />
<CollapseSettings Duration="500" Effects="expandVertical fadeIn" />
</AnimationSettings>
<ButtonsCollection>
<telerik:ChatToolbarButton Name="UploadImage" IconClass="t-icon t-i-image" />
</ButtonsCollection>
</ToolbarSettings>
</telerik:RadChat>
<telerik:RadAsyncUpload runat="server" DropZones=".RadChat" AllowedFileExtensions=".bmp,.jpg,.jpeg,.png,.gif" CssClass="chat-upload" ID="RadAsyncUpload1" OnClientFileSelected="OnFileSelected">
</telerik:RadAsyncUpload>
Reference
https://demos.telerik.com/aspnet-ajax/chat/toolbar/defaultcs.aspx
I have two pages:
a.aspx
b.ascx
The goal is to get the RadToolBarButtons on b.ascx to fire the OnButtonClick() event as defined in the RadToolBar .
a.aspx is the host page for b.ascx and has this placeholder for different RadGrids:
<div id="divMiniGrid" runat="server" visible='<%# ActiveViewID != "viewFees" %>' class="rightPane">
<sf:PaymentDetailsGrid ID="ctlMiniGrid" runat="server" class="rightPane" Visible="false" IsCondensed="true" />
</div>
b.ascx has the actual RadGrid that is loaded in a.aspx. The RadGrid has an ItemTemplated RadToolbar:
The PaymentDetailsToolbar_ButtonClick() event lives on b.ascx, but it is never fired when the RadToolBarButton is clicked. Here's the signature:
protected void PaymentDetailsToolbar_ButtonClick(object sender, Telerik.Web.UI.RadToolBarEventArgs e){...}
The only event that is fired is a.aspx Page_Load() event when the RadToolBarButton is clicked. What's going on?
I would prefer to use an SVG for the ImageUrl property of the RadToolBarButton. However, I cannot figure out how to get the RadToolBar to resize the image to match the button/text size.
When I export my SVG to 18px, it is deformed. But at a larger size, it exports fine. So, essentially I want to use that larger size, then resize it in the browser (RadToolBarButton).
How do I get the RadToolBar to resize the Image set in the ImageUrl property?
RadToolBar1.Items.FindItemByValue("buttonValue").Visible = true;
It results in the following exception:
Value property is not supported by RadToolBarDropDown
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Value property is not supported by RadToolBarDropDown
This makes using it very difficult (indeed impossible).
I note that this has come up before but it seems like the problem is being ignored
Hi,
For years I used the following code:
Dim dropDown As RadToolBarDropDown = New RadToolBarDropDown("PageSize")
dropDown.CssClass = "perPageDropDown"
dropDown.EnableImageSprite = False
dropDown.Text = GetGlobalResourceObject("Insight", "Per pagina")
dropDown.ToolTip = GetGlobalResourceObject("Insight", "Per pagina")
RadFileExplorer1.ToolBar.Items.Add(dropDown)
But after upgrading to R1 2020 i get the error:
Bericht:
Value property is not supported by RadToolBarDropDown
Stack Trace:
at Telerik.Web.UI.RadToolBarDropDown.get_Value() at
Telerik.Web.UI.RadFileExplorer.ConfigureToolbarButtons() at Telerik.Web.UI.RadFileExplorer.ControlPreRender()
at System.Web.UI.Control.PreRenderRecursiveInternal() at
System.Web.UI.Control.PreRenderRecursiveInternal() at
System.Web.UI.Control.PreRenderRecursiveInternal() at
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint)
Any clues?
Marc
Hi!
I am looking for a way to add custom attributes to RadToolbarButton to be rendered in html
When I use following snippet
RadToolBarButton button =
new
RadToolBarButton();
button.Attributes[
"data-attr"
] =
"CustomText"
;
button.CssClass +=
"tipsylink"
;
I expect to see<
a
class
=
"tipsylnk ..."
data-attr
=
"CustomText"
...>
But unfortunately I can see onlywithout data-attr attribute.<
a
class
=
"tipsylnk rtbWrap"
...>
I do use jquery to read such attributes from web controls for my custom needs.
And that works for all standard asp.net controls but unfortunately
radtoolbar implementation is different - as I understand it stores
custom attributes in another place.
I know that it is possible to read such attributes on client side using
but actually I'd like to use standard jquery $('.tipsylnk'). selector
var
toolBar = $find(
"<%=RadToolBar1.ClientID %>"
);
var
button = toolBar.findItemByText(
"Button 1"
);
alert(button.get_attributes().getAttribute(
"DisplayName"
));
and process all items in the same way.
So is it possible to render custom attributes to html element attribute
for RadToolbarButtons?