How can I select a tab programmatically of a TabContainer? and also how can I get the selected Tab?
You can set the Tab Index like...
tbcName.ActiveTabIndex = 3;
and similarly
tbcName.ActiveTabIndex// Return active tab index
Please note, tab Index start from 0
Here is a complete list of TabContainer's properties taken from here:
TabContainer Properties
ActiveTabChanged (Event) - Fired on the server side when a tab is changed after a
postback
OnClientActiveTabChanged - The name of a javascript function to attach to the
client-side tabChanged event
CssClass - A css class override used to define a custom look and feel for the tabs.
See the Tabs Theming section for more details.
ActiveTabIndex - The first tab to show
Height - sets the height of the body of the tabs (does not include the TabPanel
headers)
Width - sets the width of the body of the tabs
ScrollBars - Whether to display scrollbars (None, Horizontal, Vertical, Both, Auto)
in the body of the TabContainer
TabStripPlacement - Whether to render the tabs on top of the container or below
(Top, Bottom)
Useful links with sample code:
http://sandblogaspnet.blogspot.com/2009/04/setting-focus-to-particular-tab-in.html
tabContainer = tabContainer.control;
//Retrieving the tab using the get_activeTab method/property
var tab = tabContainer.get_activeTab();
var headerText = tab.get_headerText();
alert(headerText);
//Another way of retrieving the tab using the get_previousTab method/property
tab = tabContainer.getPreviousTab();
alert(tab.get_tabIndex());
3 Tips for Working with the AjaxControlToolkit's TabContainer Control
yourTabContainer.ActiveTab = tabIndex;
Related
How to scroll to the bottom of the license agreement, which will enable the Accept button? The browser itself does not have a scroll bar; only the agreement has it.
I have googled and tried many different solutions and still can not move the scroll bar., at all.
C# code I've tried. I also tried many other and none is working. Anyone has any idea how to make it work?
IWebElement ScrollBar => DriverContext.Driver.FindElement(By.XPath("//div[#class='frm-scrollbar height-with-eula']"));
Actions act = new Actions(DriverContext.Driver);
act.MoveToElement(ScrollBar).ClickAndHold(ScrollBar).MoveByOffset(0, 1000).Release().Perform();
What Im trying to scroll:
Html for the scroll bar section:
Used this to scroll to the bottom of the page. This works for areas where the scroll bar is inside the webpage itself. Used this in multiple pages for scrolling.
EventFiringWebDriver ef = new(Driver);
// cssStr is the css for the area that includes the scroll bar
cssStr = "div[class=\\\"max-h-370 overflow-y-auto pl-24 pr-24\\\"]";
// 10000 or any number depending on scroll distance in pixels
ef.ExecuteScript("document.querySelector('" + cssStr + "').scrollTop = 10000");
IJavaScriptExecutor js = (IJavaScriptExecutor)DriverContext.Driver;
// by is to be constructed and passed
IWebElement ele = Driver.FindElement(by);
js.ExecuteScript("arguments[0].scrollIntoView(true);", ele);
I want to open a regular .aspx page in a rad window.But the regular page consists of Site Map.I don't want that sitemap to be displayed when it is opened in rad window.
Please suggest me some solution.
I already tried this:
this.MasterpageFile="..//test.Master";
But in my page it does not work
So you will have ContentPlaceHolders which will automatically inherit from the master page. If you go to the regular .aspx page and head into Design view you will see sections with all the content from the Master Page.
If you click the little right arrow to the right of the area that looks like a Div, you should be able to change the content back to what you have in your regular aspx page.
Make a public property on MasterPage to show hide your site map , on your rad window page access that Property and make it hide.
public bool MyProperty()
{
// get and set your controls visibility
}
Access your property like this.Master.MyProperty = false
I am using ASP.NET and C# and I am using window.open() for opening the window.Now i need to set the width of that page in that window.
I am using this code on buttonclick event.
ClientScript.RegisterStartupScript(this.GetType(), "oncl", "<script language=javascript>window.open('Print.aspx','PrintMe','width=900,resizable=1,scrollbars=1');</script>");
The width inside the script is only setting the widow width. But i want to set the width of the page.
Is it possible?
Thanks..
Edit:
Sorry I didn't mention it before.I am writing the content into print.aspx dynamically.That i am using this code for fill the page.
Page pg = new Page();
pg.EnableEventValidation = false;
HtmlForm frm = new HtmlForm();
pg.Controls.Add(frm);
frm.Controls.Add(ctrl);
pg.DesignerInitialize();
pg.RenderControl(htmlWrite);
string strHTML = stringWrite.ToString();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write(strHTML);
This is called on pageload event. So i am printing the .aspx page in print.aspx. So i want this content should be in the static page width.
Width specified inside window.open() function will only set width of the popup window. If you want to change the width of the page then you should try changing the width inside Print.aspx.
You cannot change width of the page using window.open, it only sets the window properties.
To change the width of the page you need to change the style of print.aspx
probably if you have to change the width of the wrapped div element or body of the page
var newwindow = window.open('Print.aspx');
var elem = newwindow.document.getElementById('my-id');
elem.style.width = 'XYZpx'
P.S. :- The above code will only work if the new window has the same protocol, domain and port. If it's on another domain, you can't do this for security reasons.
You can also use
window.resizeTo(x,y);
For Instance:
function resizeWindow()
{
// you can get height and width from serverside as well
var width=400;
var height=400;
window.resizeTo(width,height);
}
On onload() event of body call the function
<body onload="resizeWindow()" >
body of page
</body>
In case which you're using that page only with the window.open method then set the width of the page respectively hard-coded, otherwise, inject the size while opening the page using window.open.
How to inject while opening:
Access child window elements from parent window using Javascript
(Notice to security issues on Cross-origin resource sharing)
In short:
var childWindow = window.open('Print.aspx','PrintMe','width=900,resizable=1,scrollbars=1');
childWindow.document.getElementById('someDivId').style.width = '400px';
Or access it at the server-side:
HtmlForm frm = new HtmlForm();
frm.style = ; //
read here
How to set it hard-coded:
Width of which element in the window you want to change?
body?div?
I guess you you're taking about the margin left & right of your page's body.
try insert the following style block to your head tag:
<style>
body{margin: 0 10px 0 10px;}
</style>
where 10px is the left and right margin.
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.
I have an aspx page which contains a no. of div with varying no. of controls.
and evey div is visible through a tab menu i.e. on clicking of a tab in menu a div is made visible or false.
Now for my requirement I want to check if a user has made some changes in the foem fields and if it changes any of the field, a message should be displayed showing "Your changes have not been saved".
How can I accompalish this if you could guide me please.
Thanks in advance.
var formChanged = false;
// doc ready
$('#formId').change(function(){
formChanged = true;
});