fill AspxPopupControl with aspxGridView - c#

Im using aspxPopupControl with AspxGridView in it. Is it possible to set control to fill all popup cause now when I try to resize that popup there is a lot of free space at the top and bottom when I increase width od the popup. Thanks for help

Did you take a look at the new ASPxGridLookup control? I would assume that it is just what you need.
Also, see the online documentation of the ASPxGridLookup control.

Gruber,
Try the approach mentioned in this issue Q253230:
<dx:ASPxHtmlEditor ID="ASPxHtmlEditor1" runat="server" Height="100%" Width="100%" ClientInstanceName="HtmlEditorBody" ResizingMode="Postponed"></dx:ASPxHtmlEditor>
<dx:ASPxPopupControl ...>
<ClientSideEvents
AfterResizing="function(s, e) {
HtmlEditorBody.SetHeight(s.GetHeight() - 25); HtmlEditorBody.SetWidth(s.GetWidth() - 25);
}"
BeforeResizing="function(s, e) {
HtmlEditorBody.SetHeight(MIN_SIZE);
HtmlEditorBody.SetWidth(MIN_SIZE);
}"
/>
While that code is for the ASPxHtmlEditor, you can adapt it for the ASPxGridView.

Related

How to change background of CKeditor from code behind C#

Simple question really. How can I change the background color of the CKeditor from C#?
How do I get an instance of CKeditor in C#? Probably I cannot?
I have a gridview with lots of textareas (asp:textbox) controls all using the CKeditor, via the CSSclass property, and it works great! But now I want to dynamically change one or two, or all of their background colours to something like LightYellow.
I've tried to directly change the background of the asp:textbox, but it doesn't work of course because that's "hidden" from the CKeditor itself.
Any other tips please?
UPDATE
I've downloaded the CKEditor for ASP.net and it too does not work, as it also creates a textarea element in the background automatically - effectively the same as using the CKeditor natively with CSSclass="".
Referencing the control in C#, I can do that now, which is great so I can get the data and use it in my database, but I still cannot change the CKeditor's background. The CKeditor's BODY element (tested via FireBug), is the one I need to change, but how from C#?
Thanks again
First, be sure you have installed both CKEditor and CkeditorForASP.NET packages via Nuget.
Afterwards, create an editor.css file which will contain only editor related styles such as:
.lightYellow {
background-color: lightyellow;
}
On your grid view, bind to OnRowDataBound event and specify base path of CKEditor scripts correctly.
<asp:GridView ID="EditorGridView" runat="server" OnRowDataBound="EditorGridView_RowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<CKEditor:CKEditorControl ID="Editor" runat="server" BasePath="~/Scripts/ckeditor" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Then you will be able to change the body color as follows:
if (e.Row.RowType == DataControlRowType.DataRow)
{
CKEditorControl editor = (CKEditorControl)e.Row.FindControl("Editor");
editor.BodyClass = "lightYellow";
editor.ContentsCss = ResolveUrl("~/Content/editor.css");
}

Display an image for a TreeNode

I try to display Images at a node in a Treeview. The Treeview is in an ascx control cause i need it multiple times.
I use the following code:
<asp:TreeView ID="FolderTree" runat="server" BackColor="White">
<NodeStyle ForeColor="Black" ImageUrl="~/App_GlobalResources/folderClosed.png" />
<ParentNodeStyle ImageUrl="~/App_GlobalResources/folderOpen.png" />
<RootNodeStyle ImageUrl="~/App_GlobalResources/folderOpen.png" />
</asp:TreeView>
Thsi code semms to be right for me, and its also displayed right in the designer.
But when i start the page, not a single picture is shown. Only the default collapsebuttons are visible.
What am i doing wrong?
Many thanks in advance.
Edit: I added the code how i populate the control
private void Page_Load(object sender, System.EventArgs e)
{
try
{
if (!Page.IsPostBack)
{
var devData = Foo.GetDevices(); // returns a list with all devices
foreach (string temp in devData)
{
this.FolderTree.Nodes.Add(new TreeNode() { Text = temp, ImageUrl = "~/App_GlobalResources/folderOpen.png" });
}
}
}
catch(Exception error)
{
//errorhandling
}
}
Edit 2: I assume i have that bug: forums.asp.net/t/943367.aspx but the suggested Solution isnt working! (see code above, i already set the value via code. Does anybody know a solution/ a hotfix (to use in an webusercontrol(.ascx))?
I also tried (on my base site):
protected override void OnSaveStateComplete(EventArgs e)
{
foreach (TreeNode tmpNode in this.LeftSelectControl.AccessFolderView.Nodes) //AccessFolderView = var, which contains the treeview of the ascx (to access it)
{
tmpNode.ImageUrl = "~/App_GlobalResources/folderOpen.png";
}
}
Use the DHTMLX Tree View a Open source javascript library that combines well in C# Fluidly. It will produce nice tree view with images.
Its very simple to use in C# aspx page.
Click Here for Dhtmlx tree
Never done the way you styled your TreeView.
But this is how i style my Treeview. Hope it helps you.
<asp:TreeView ID="treeView" runat="server" NodeIndent="20" ExpandDepth="0" NodeStyle-HorizontalPadding="2"
ShowLines="true" ExpandImageUrl="../images/Open_Folder.png" CollapseImageUrl="../images/Close_Folder.png"
ForeColor="Black">
</asp:TreeView>
I found a Solution: Dont use App_GlobalResources.
I wont mark this as answer cause this was an stupid mistake by me. You can access App_* Folders only serverside, not clientside.

OnClick button to refresh textbox not working

I have the following code in the code behind. Goal is to reset the value of the textbox to blank. When I click the button, however, nothing happens.
protected void btnReset_Click(object sender, EventArgs e)
{
Label srch_Title = (Label)FindControl("srch_Title");
srch_Title.Text = String.Empty;
}
Here is the textbox code from the main page:
<asp:TextBox ID="srch_Title" AutoPostBack="true" runat="server" />
Here is the button code from the main page:
<asp:Button ID="btnResetSearch" runat="server" OnClick="btnReset_Click" Height="35px" Text="Reset Search" Width="120px" />
I am a novice / enthusiast programmer and this is my first post. Guessing the problem is obvious and I am just not seeing it.
You should define your control as TextBox not Label , like this :
TextBox srch_Title = (TextBox )Form.FindControl("srch_Title");
srch_Title.Text = String.Empty;
You need to find the srch_Title control as a TextBox instead of as a Label, like this:
// The as operator avoids a cast exception,
// returns null if cast cannot be successfully performed
TextBox theSrchTitleTextBox = Form.FindControl("srch_Title") as TextBox;
// Verify that we found the text box before we try to use it,
// to avoid null reference exception
if(theSrchTitleTextBox != null)
{
theSrchTitleTextBox.Text = String.Empty;
}
Figured this out by adding another FindControl. First FindControl referred to the master and used the results of that to setup a second FindControl pointed at the text box. I did not post enough code when I asked the original question as I think an experienced programmer would have quickly spotted the solution. Thanks to all who contributed.

Adding style to CommandItemSettings RadGrid button

I am trying to add a red asterisk after the 'AddNewRecordText' button with in RadGrid. Here is the code. The red asterisk should show after 'Add Award' text. Could you please let me know if there are any suggestions? Thank you.
<telerik:RadGrid ID="RadGrid1" AutoGenerateColumns="false" Width="99%"
runat="server" MasterTableView-AllowAutomaticInserts="true" GridLines="None" Skin="Default"
ShowFooter="false" ShowStatusBar="false">
<MasterTableView Width="100%" DataKeyNames="c_id" CommandItemDisplay="Top"
CommandItemSettings-ShowAddNewRecordButton="true">
<CommandItemSettings AddNewRecordText="Add Award *" ShowAddNewRecordButton="true" />
RadGrid prerenders AddNewRecordText as a <a> element. and you cannot add different styles to one element.
To change that default behavior, you will have to use CommandItemTemplate.
This demo should be a good start for you.
Another simple approach, is that you always can change any style on your page with jquery.
this should work for you (works for me, probably you will have to change ids):
$('a[id$="InitInsertButton"]') //this means: find all <a> elements that have id ending with "InitInsertButton"
.first() //Get the first element to be sure.
.append('<span style="color:red"> *</span>') //Add text inside a attribute.
You will have to add this code on document.ready().
Here's a small jsfiddle to see it in action: http://jsfiddle.net/rXhnM/
So I'm late to the party again, but you can get a reference to that control on the server side:
protected void HandleGridItemCreated(object sender, GridItemEventArgs e)
{
if(e.Item is GridCommandItem)
{
var button = e.Item.FindControl("SaveChangesIcon") as Button;
var link = e.Item.FindControl("SaveChangesButton") as LinkButton;
button.Text += "<span class='red'>*</span>";
}
}
I needed to add a bit of javascript to run when clicked so this is how I managed to pull it off. I imagine adding * and appending to the text property yield the result you're looking for. We're on the 2016 version of the Telerik control set.

Is that possible to set a multi-line textbox a background image?

I have a textbox control (multi-line enabled). Is that possible to assign it a background image?
I'm assuming this is a WinForms application?
There is no 'built-in' way of doing this. You can override the controls paint method (onPaintBackground - I believe) and draw the image yourself.
If it's Web based or WPF - you're in luck.
It's possible. Just add the image location to the text box styling:
<asp:TextBox id="TextBox1" runat="server" style="background-image: url( images/myTextboxImage.jpg ); border: none;" />
EDIT: As Rob pointed out in his answer: this is only if you're doing it on the web.

Categories