Visibility of ajaxToolkit:TabContainer using css - c#

I use ajaxToolkit:TabContainer to organize page contents. Some times, I need to hide some tabs based on conditions. The problem is, I would like to read the content of hidden tab using JavaScript. So I can not use C#'s Tab.Visible = false because it will not render the tab.
When I use CSS's display:none; or visibility:hidden;, the tab still there (without tab titles). I guess Ajax tab does not support the css properties. What are the alternatives should I use ?

You can use TabContainer1.Tabs[0].Enabled = false; to hide tab, it will still generate the DOM element for this tab and you can access it using javascript.

Related

Change font-weight of an asp:RadioButton Text in client script

I have 2 asp:RadioButton that are unchecked when the page is loaded. When one is checked, I want to change the font-weight to bold in client script. I tried:
radio1.style.fontWeight = 'bold';
but it didn't work.
You can access the the css class using the attributes property. I am assuming radio1 is the id if so you could modify your c# code to
radio1.Attributes["class"] = "newCssClassName";
I personally have never modified a single property of css using c#. To do that I have always used something like jQuery.
Try to create a new css class such as
.rbSelected
{
font-weight:bold;
{
And then toggle them accordingly ( your css property should be font-weight not fontWeight)
Also a word of warning with controls such as radio buttons and checkboxes the browser will override your styling in most cases. Each browser will render the control differently regardless of what style(s) you apply. If you are looking for something custom you may need to create your own control/element (Such as an image/element that looks like a checkbox but has manages states handled in code)
For bold
$("#YourElementID").css("font-weight","bolder");
For regular
$("#YourElementID").css("font-weight","normal");
You can create a function with this lines to toggle the font-weight. To call the javascript function from the server side controls use:
radio.Attributes.Add("onclick","functionname()");
This will add the functionname to the onclick event when the radio button is rendered to the browser.

Selenium WebDriver with RadWindow

I am attempting to access a form within a RadWindow. The web page uses window.radopen() to generate an ASP.NET popup. I need to access that popup, edit it, and click a button. Is there a way to do this using Selenium WebDriver?
Specifically, the radwindow contains a textarea with an id of "txtEntries" and a button with and id of "btnAccept". I have tried finding the textarea first, as below, with no luck.
I am currently attempting:
state = wait.Until<IWebElement>((d) =>
{
return d.FindElement(By.CssSelector("div#radWindow #txtEntries"));
});
With failed results.
Yea, there's a way.. Since RadWindow is not an actual window, it makes it significantly easier.
First, use CSS and have a parent selector. Something like,
div#radWindow
Then just add the elements you want to find to that. e.g.
input[type='text'].someclass
then just concatenate them, so it turns into this -
div#radWindow input[type='text'].someclass
which translates in CSS to "first find a div with id radWindow, and find an input that is a descendant of the div, with the type attribute that equals text that has someclass attached.

Watin Visible of Text

I'm Using Watin tool in C# to find a text is available in webpage/URL. Using the code:
bool flag = browser.containsText("Some Text");
But returns true, but the text("Some Text") is hidden in page. I need to get only visible text of a URL. i Dont Have the ID/Name of the Element...
Find the control that is hidden and check to see if it is visible and contains the text.
Example if it were a Div and using NUnit:
Assert.IsTrue(myBrowser.Div.Style.GetAttributeValue("visibility") == "hidden" && myBrowser.Div("myPossiblyHiddenDiv").Text.Contains("the text"));
Lots of ways to check for the text; I usually try to go as granular as possible in case there are other controls on the page that contain the text in question.

change Visibility of a control in ASP.NET code behind (c#)

How do you set the visibility of a (fileupload) control from ASP.net code (I need to hide a fileupload control in a webuser control from server site, otherwise hasFIle is always false).
Also setting the "Visible" property to false does not work (as is confuses the AJAX panel so the fileupload forgets that it has a file).
theFileUpload.Visible = false => does not work
so I want to try to set the CSS style visibility to hidden or display to none.
The main problem is I want to do it from the server side (I know how I could do it on client).
Is there a safe way to overwrite
theFileUpload.Attributes["styles"]
in case I modify other CSS styles in there,
also throwing a whole CSS class at it (by moidifying the CSSClass property) seems like overkill.
thanks in advance
Axel
By using theFileUpload.Visible = false; you just tells to asp.net to not render theFileUpload on the page.
You may use
theFileUpload.Attributes.CssStyle[HtmlTextWriterStyle.Visibility] = "hidden";
That allows you to set only a specific css property.

Navigating between DotNetNuke module controls using EditURL() or NavigateURL()

OK I'm new to DotNetNuke and need to write a simple module in DNN that will display an article for everyone, and allow the admin to edit the article/add a new one.
I have a test page that contains a DNN module with one module definition and two controls in that definition. The default control shows the article based on an articleID field in the querystring. You then click a button that is supposed to load the edit control and pass the articleID in the query string.
If I use EditURL() in the onClick the edit control is loaded with the correct articleID, but using the admin skin. If I use Globals.NavigateURL() then the correct skin is shown but my edit control isn't loading in the page.
Any clue as to how to what I'm doing wrong or how to get the edit control loading with the correct skin?
My two methods of switching to the edit control (in my button click event) are listed below:
string newURL = this.EditUrl("articleID", Request.QueryString["articleID"], "EditArticle");
Response.Redirect(newURL);
and
string newURL = Globals.NavigateURL(this.TabId, "EditArticle","articleID="+Request.QueryString["articleID"]);
Response.Redirect(newURL);
Actually you are doing this correctly - the editurl in DNN does load the Admin skin - usually this skin is based on someone administering content so it strips out all other modules and shows the 'basics'. Right or wrong this is what it does.
If you dont want to to do that you could provide a switch in the querystring and show a seperate panel or do a multiview control and show different views based on the switch in the query string.
There are a few other approaches like changing the content area to editing text area with ajax or using popup modal style windows.

Categories

Resources