to set value parent page's frame from popup - asp.net

I want to set label's value from popup.But label is in frame and I dont know how to achieve it from popup. From parent page,i get this label by following javascript function.
But when I use this function in popup page, I cant find topframe.Do u have any solution about how to success it?
if (window.parent.document.getElementById('lbl'))
{
window.parent.document.getElementById('lbl').innerText = sender.getSelectedItem().get_text();
}
else
{
window.parent.frames['topFrame'].document.getElementById('lbl').innerText = sender.getSelectedItem().get_text();
}

window.parent
refers to your popup-window itself.
Try
opener.frames['topFrame'].document.getElementById()
instead - 'opener' refers to your main-window out of a popup.

window.parent.top.frames.document works

Related

keyman.setDefaultKeyboardForControl(Pelem, keyboard, languageCode); function is not working with iframe element

It is showing warning that 'keymanweb.setKeyboardForControl' cannot set keyboard on iframes.
I want to manually set specific language of keyman on iframe element.
Please help me out to achieve the same.
While keymanweb.setKeyboardForControl cannot be used with iframes, you should be able to use a controlfocused event event to select a keyboard on entry to the control:
keyman.addEventListener('controlfocused', function(eventProperties) {
if(eventProperties.target == myIframe) {
keyman.setActiveKeyboard(...);
}
return true;
});

Dojox DataGrid : lose focus on a cell when validating?

I have a popup with a DataGrid (with editable cells) and a validating button. If I set a value in a cell just before and don't leave it by selecting another cell, I don't get this value when validating. I know how to go through each cell of this grid and see if there is a focused one :
dojo.query("#myGrid .stdCell").forEach(function(node, idx){
if(dojo.attr(node,'class').indexOf('dojoxGridCellFocus') > -1) {
// But what to do here?
}
}
I think I have to blur this cell or focus another element of the popup but how can I do that? Or is there a simpler a function for this?
Thanks for your help.
Finally got it working with a little workaround.
I added to my grid :
onBlur="onTableBlur"
And in my JS file :
var onTableBlur = function() {
if (this.edit.isEditing()) {
this.edit.apply();
}
};

How do I know if a tab is selected?

I am trying to get a report based on different information located in tabs. How do I know If a tab is selected? I looked for something like:
if(colorListTab.isSelected)
{
}
but no luck! Can you guys help me out with this?
You could use the ActiveTab property, for example(in ActiveTabChanged):
if(TabContainer1.ActiveTab.Equals(colorListTab)){
}
or you could use the ActiveTabIndex:
if(TabContainer1.ActiveTabIndex == 1){ //second tab
}
http://www.dotnetcurry.com/ShowArticle.aspx?ID=178
Try using ActiveTabChanged event
Also please have a look at this question AJAX ToolKit TabContainer: Can I capture the “Active Tab Panel Changing” event
The property you're looking for is "ActiveTab", a property of the actual TabContainer (not an individual tab)
if(colorListTabContainer.ActiveTab.TabIndex == 1)
{
//You only get here if the index of the active tab is 1
}

How can I get value from radio-button inserted into innerHtml

I have sort of a table with a radio-button column. I managed to make radio-button column work dynamically inserting into a cell (div if matter). But, on postback innerHtml hasn't been updated with "checked" attribute.
Could you give me an idea how can I find out (on the server) if radio-button has been checked?
More info: This is on user control inside update panel.
This would be good post on my topic, still doesn't help
Any reason you cannot use a standard asp:RadioButton and use javascript to ensure it is mutually exclusive. I have done this before by adding a custom attribute to the radiobutton and then using a js function to uncheck all items with that attribute and then check the selected one. This works around the IE issue which prevents the groupname attribute from working on radioboxes that are in different containers.
radioButton.InputAttributes.Add("ClientGroupName", "grpRadioList");
radioButton.InputAttributes.Add("onclick",
string.Format(
"javascript:radiobuttonToggle('{0}','ClientGroupName','grpRadioList');"
,radioButton.ClientID));
and use the following JS to uncheck all radios and then check the one you want.
Note i used InputAttributes instead of Attributes as the radiobutton is wrapped inside a span tag so InputAttributes is for items added to the actual input control rather than the span.
function radiobuttonToggle(selectedRB, attribName, attribValue)
{
var objRadio = document.getElementById(selectedRB);
for(i = 0; i < document.forms[0].elements.length; i++)
{
elm = document.forms[0].elements[i];
if (elm.type == 'radio')
{
if(elm.getAttribute(attribName) == attribValue)
elm.checked = false;
}
}
objRadio.checked = true;
}
You can then expose radioButton.Checked as a property in your CS file and reuse this as a control.
Check Form.Request("radio-name") != null
You only get a non-null value when it's been checked.
Make sure your page elements are being rebuilt correctly on postback. Any binding process that inserted the radio buttons the first time around will have to be re-run before you can access them the second time.
Here is a working example, first I add radios to my webform by the method you linked :
function addRadio()
{
try{
rdo = document.createElement('<input type="radio" name="fldID" />');
}catch(err){
rdo = document.createElement('input');
}
rdo.setAttribute('type','radio');
rdo.setAttribute('name','fldID');
document.getElementById('container').appendChild(rdo);
}
Then at code behind I used only the code below to get the radio's value :
string value = Request["fldID"];
So, be sure you're trying to get the name of the radio buttons at server side. You should use name attribute at server side, not id.

OnClick event for whole page except a div

I'm working on an own combobox control for ASP.Net which should behave like a selectbox, I'm using a textbox, a button and a div as a selectbox replacement. It works fine and looks like this Image:
My problem now is the Selectbox close behaviour: when clicking anywhere outside the opened selectbox it should close.
So I need something like an onClick event for the whole page which should only fire when my div is open. Any suggest how to do that?
Add a click event handler to document. In the event handler, examine its target (or srcElement in IE) property to check that it isn't your open div or any of its descendants.
Set a click event handler on the document that "closes" the pseudo-combobox. In addition, set a click event handler on the pseudo-combobox's container (the div, in this case) which cancels bubbling of the event. Then any clicks in the div will bubble up only as far as the div before being halted, while clicks anywhere else will bubble all the way up to the document.
This is a much easier option than mucking around traversing the DOM from the event's target upwards to work out where the click came from.
EDIT: if you are setting the div's style to display: none; (or something similar) to hide it, then it doesn't matter if you leave the event handler on the document - hiding it when it's already hidden will have no effect. If you want to be very tidy, then add the event listeners when the div is shown, and remove them when it is hidden; but there's probably no need to bother.
document.onclick = function() {
if(clickedOutsideElement('divTest'))
alert('Outside the element!');
else
alert('Inside the element!');
}
function clickedOutsideElement(elemId) {
var theElem = getEventTarget(window.event);
while(theElem = theElem.offsetParent) {
if(theElem.id == elemId)
return false;
}
return true;
}
function getEventTarget(evt) {
var targ = (evt.target) ? evt.target : evt.srcElement;
if(targ && targ.nodeType == 3)
targ = targ.parentNode;
return targ;
}
Put a transparent div that covers whole the page and lies under your dropdown. At that div's click event hiğde your dropdown.

Resources