Is it possible to trigger AJAX CollapsiblePanelExtender animation from code behind? - c#

I am using an AJAX CollapsiblePanelExtender for several sections of a form. I can collapse a panel programatically using the following 2 lines:
ajaxCollapsiblePanelExtender1.Collapsed = true;
ajaxCollapsiblePanelExtender1.ClientState = "true";
However, the expand/collapse animation does not play as when the Expand/CollapseControlID is clicked. It simply appears in the collapsed state. Is it possible to trigger this animation programatically?

You could open it by clicking the object with javascript/jQuery when you return from the server
I think this may be the only way to get what you want

Related

Hide button text behind button image

Is there any method to hide a button text behind button image like bring to front or send to back option?
I only need to hide or show button image only as I have a code that coverts the original text CloseButton.text = "&Close"; to CloseButton.Text = "&Cancel";
to perform another command so I can't use CloseButton.Text = "";.
Tried this link - WinForms button with image and text but my button size is too small that it would only show the text and not the image no matter how I mix and match TextAlign and ImageAlign.
Any help is much appreciated. Thanks in advance.
Sample Button Size below:
Check this
Place Textbox in Button and set textbox.visible=false method
Is there any method to hide a button text behind button image like
bring to front or send to back option?
There is no such built in but you can simply clear out the text on click event of the controls. Example: if you have radio buttons for send to back then on click of that clear out the control text saying controlId.Text = string.Empty
As #Rotem posted in the comments.
Have your code behind use the Tag property rather than Text. Easiest way out is using properties for what they were made for.
Instead of using CloseButton.text = "&Close"; I changed it to CloseButton.Tag = "&Close"; and made my code worked around it to have the same function without placing an actual Text in my Buttons. Credit this asnwer to #Rotem. Thanks.

How to make a listbox appear on the form at the click of a button?

I'm a university student therefore I'm not sure on everything to do with writing code. If you could provide hints or a bit of help. I have hidden the listbox via the designer. I've tried listbox1.Show under next button event handler. I've tried looking around on the web but I'm getting no where.
Now answered. Thank you
The solution depends on how you've hidden your listbox. If you did set visible property to false, just use listbox1.Visible = true;.
If you used ' Send to back' to hide it behind another control, you can use listbox1.BringToFront(); to set it into the foreground.
See https://msdn.microsoft.com/en-gb/library/system.windows.forms.control.visible.aspx and https://msdn.microsoft.com/en-gb/library/system.windows.forms.control.bringtofront.aspx
Inside Button_Click Event write:
listbox1.Visible = true;
In my opinion, the best way to show/hide controls (in WPF) is to collapse them. This allows the rest of the controls to behave as if the collapsed control does not even exists, until it is made visible, of course.
This would be done like so:
control1.Visibility = Visibility.Collapsed;
control1.Visibility = Visibility.Visible;
If you are using WinForms, controls will not have a collapse option, and the correct way would be as Almansour has said.

how to create drop down panel with two steps

I would like to create a drop down panel that when you collapse it, it will close only half and when you expand, it will expand and show the other items as shown in below image.
I already tried to use SplitConatainer and by hide the panel manage my work but my problem is when I collapse it the other items not rearrange. please refer to below image.
button code:
if (splitContainer1.Panel2Collapsed)
splitContainer1.Panel2Collapsed = false;
else
splitContainer1.Panel2Collapsed = true;
Also I tried to set size of panel but it is not rendering and effecting.
would you mind help me in introducing some previous work that have ability of customization. Or help me to start create such component please?
I solve my problem by add a parameter to project "ExpandCollapsePanel" in GitHub.
So Just by adding a value to MaximumCollapseHeight, you can control panel.
you can get the source code from here.
enter link description here

Push Button (On/Off) in C# Windows Forms

On the Windows Form application I have a Lamp image (a black and white one, and a bright one. For OFF and ON respectively).
Using the Button how can I achieve the scenario such that same button will turn the property of the image (pictureBox in my case) to show the Lamp as ON and pressing the same button again will turn the Lamp off.
I am accessing the 'Visible' property of picture box.
Put two images on top of each other and get the button to switch which one of them is enabled.
In the form designer you make one of them visible and the other non-visible. The code in the button handler can then be something like:
lightImage.Visible = !lightImage.Visible;
darkImage.Visible = != lightImage.Visible;
That will swap which one is visible and eliminate the need to keep state elsewhere.
A bit late to the party, but you can use a checkbox and set the appearance to button.
I think that would do what is expected by the original post.
I'm not sure about the way to put 2 images over each other, but if you want to reach the same effect:
place the 2 image files in your project resources
in the click event of the button, toggle the button image depending on a setting:
this would be in the click event:
Properties.Settings.Default.IsOptimizedForTracer !=Properties.Settings.Default.IsOptimizedForTracer;
if (!Properties.Settings.Default.IsOptimizedForTracer)
{
btnOptimizeForTracer.Image = Properties.Resources.TracerOFF;
return;
}
btnOptimizeForTracer.Image = Properties.Resources.TracerON;

Watin script for handling Ajax popup

I'm using WatiN testing tool and i'm writing c#.net scripts. I've a scenario where i need to change the theme of my web page, so to do this i need to click on a image button which opens a ajax popup with the image and "Apply Theme" button which is below the image now i need to click on the button so how to do this please suggest some solution.
So first click your button that throws up the popup, and .WaitUntilExists() for the button inside the popup.
IE.Button("ShowPopup").click()
IE.Button("PopupButtonID").WaitUntilExists()
IE.Button("PopupButtonID").click()
This may not work in the case the button on the popup exists but is hidden from view. In that case you could try the .WaitUntil() and specify an attribute to look for.
IE.Button("ButtonID").WaitUntil("display","")
The Ajax pop-up itself shouldn't pose a problem if you handle the timing of the control loading asynchronously. If you are using the ajax control toolkit, you can solve it like this
int timeout = 20;
for (i=0; i < timeout; i++)
{
bool blocked = Convert.ToBoolean(ie.Eval("Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack();"));
if (blocked)
{
System.Threading.Thread.Sleep(200);
}
else
{
break;
}
}
With the control visible you then should be able to access it normally.
Watin 1.1.4 added support for WaitUntil on controls as well, but I haven't used it personally.
// Wait until some textfield is enabled
textfield.WaitUntil("disable", false.ToSting, 10);
I'm not using any ajax control toolkit and in the popup there is no text field as i've mentioned there is only a image and a button below it, which i need to click in order to apply that image as theme.
I wrote a post about how I do ajax synchronization, since I was having problems with WaitUntilExists: http://lebobitz.wordpress.com/2011/03/06/synchronizing-watin-and-ajax-with-jquery/

Categories

Resources