Problem context:
1) rcbComboBoxInRadPanel is a Telerik RadComboBox.
2) rcbComboBoxInRadPanel has "OnClientSelectedIndexChange" event which fires "itemSelected."
3) rcbComboBoxInRadPanel is contained a radAjaxPanel called "foo."
4) strSomeOtherRadAjaxPanel names a RadAjaxPanel that exists outside of "foo."
5) $find(strSomeOtherRadAjaxPanel) returns a valid RadAjaxPanel if executed alone.
function itemSelected(rcbComboBoxInRadPanel)
{
var strComboBoxInRadPanel = rcbComboBoxInRadPanel.get_id();
var intRecordID = rcbComboBoxInRadPanel.get_value();
$find(strSomeOtherRadAjaxPanel).ajaxRequest(intRecordID);
}
It appears that $find(strSomeOtherRadAjaxPanel) always returns null when called from the "OnClientSelectedIndexChange" event of rcbComboBoxInRadPanel.
Is there another way for me obtain a valid reference to the RadAjaxPanel using $find(strSomeOtherRadAjaxPanel)?
Any help you can offer would be helpful.
Can you obtain reference to the strSomeOtherAjaxPanel from other client handler of the combo or when it is moved outside of its ajax panel holder? If the strSomeOtherAjaxPanel is initialized properly on the client, it should be available in each of these cases.
check your rendered html source code. ASP dynamically generates clientID names so your server side IDs may not have persisted. They probably now look something like ctl100aFMLksdjflFML
Either target them some other way (like class name, jQuery search, etc) or set the client ID mode to static (if it is the only instance of this object) then try again.
Related
I have a macro which remembers a previous clicked ID for the next event, which is quite handy and it works fine. When I use the macro in a firing rule, where the firing rule is not used, it also works good. However, when I use the firing rule for a Tag, it get's calculated twice and so it forget the previous clicked ID and only returns the current clicked ID. Is there a way to let this Macro only be calculated once?
Set a cookie in your macro
document.cookie="hasexecuted=true";
Create a second macro of the cookie type and name it e.g. "hasexecuted". Use it to check for the presence of the cookie. The cookie macro will be filled in with a value before any custom javascript values, so you can use it's return value in your custom macro function:
function() {
if({{hasexecuted == true}}) { return; }
....
}
Google Tag Manager does not have any memory all by itself so you need to implement your own storage and for such a simple thing a cookie might be easiest (if course this means a wee bit more overhead since cookie data is send to the server, so you might want to use localstorage or something like it).
I am new to Web UI, Dojo, Java etc. If you are referring any advance topic please give some reading reference. It will help.
Context:
I have Gridx design using JsonStore, which takes a target + id for URL. With fixed "id" Grid loads well.
I have Dynamic Tree. It is working fine with lazy-loading etc.
Objective:
Based on click (or dblclick) event for a given node in Tree, I have to load Gridx with data. Hence, if tree node "id":7 is clicked, then JsonStore: /target/7 should be fetched and get loaded in Gridx.
Issues:
As you can guess, at start there is no valid "id" property to fill in JsonStore. In click event handler of tree, I will get this value, upon a user click. Hence, can't call gridx.startup() in "ready". Though I have "placed" the widget in "ready".
Hence, I have following snippet to handle,
<
// this function is called from tree event handler
function LatestTabGridxLoad( id ) {
console.log( "ID %s fetched.", id );
LatestTabGridxStore.idProperty = id;
LatestTabGridx.startup();
LatestTabGridx.body.refresh();
}
ready(function()
{
TabLatestAssetTree.startup();
LatestTabGridx.placeAt( "ReportMiddleTabLatestCenterContainer" );
}
Now, trouble is, at first time loading, JsonStore GET fired with /target/ alone, without any "id" without any user click. Hence, server responds with 405. Subsequently, when user clicks, again same HTTP GET without "id" results in HTTP 405. I am not able to somehow feed "id" to the GET URL. I have checked JSON, it is in perfect shape, as it works in standalone table, that is declarative(ly) defined.
Please suggest me ways to link a TREE node through its "id" to Gridx. Also suggest, if approach I am taking is right way to solve this problem.
Sorry, misunderstanding of the question. I thought it was about gridx tree but it is about regular gridx controlled by another widget.
The problem is in this line:
console.log( "ID %s fetched.", id );
LatestTabGridxStore.idProperty = id;
'idProperty' is the name of the JSON attribute which stores the ID. This will not change with each selection. If it is not set, JsonStore will assume it to be 'id'. What you intended to do was to modify the target property of the store to include the ID. This can done directly and will look something like the following (details are application specific)
LatestTabGridxStore.target = (someURL) + '/' + id;
After that, the content of gridx needs to be replaced using the new store setting. There are few ways to do it, the simplest being destroying the current gridx instance and replacing it with another one which uses the altered store.
I need to make multiple validation summaries validate their controls and display any error messages.
I have a large form that I've broken into separate panels, each with it's own validation group and summary. I have one button that must validate the entire page and cause all the validation groups to be validated and show the error message.
My idea is to just iterate through a collection of Validators/Validation Summaries/Validation Groups in the code behind and fire their validate events, but I'm having trouble implementing it so that the validations summaries/errors appear on the page. Any ideas?
EDIT: I made a JavaScript function to try and get it working on the client side
<script type="text/javascript">
function validate() {
var t1 = Page_ClientValidate("vgpEmpInfo");
var t2 = Page_ClientValidate("vgpPanelA");
if (!t1 || !t2) return false;
return true;
}
</script>
But this only validates and displays the last validation group called, in this case Panel A.
So you are looking to do it all on the client then, not the server? The server would be easier as you could call Page.Validate("group"), and that would work for all the validation summaries.
Page_ClientValidate I didn't realize that would hide all the groups... but what you could try to do is call Page_ClientValidate for all. Now I'm not sure, but I think that it might just hide the <ul> representing the list, but I'm not 100% sure, so you may be able to just show all the <ul>'s representing each summary.... otherwise, you'd have to look at validatorValidate client method. Never done this, but seems like this might work, though the latter is going to be a real pain because you have to examine custom attributes on the validator span, and process accordingly.
HTH.
Is there a way to get the selected value (or text, or index) of a select box that the server fills (using ASP.NET) in the client? I've tried $("#ID").val() - but the only time that works is when I continue to another page and then go back. Even then, the value that is returned is the previously selected value - if the user changes the selection, it's not registered unless they leave the page and go back. Go easy on me, I'm new at this...
Update: Tried using a regular html select, same issue (just with a populated entry). Let me elaborate on what I'm trying to do: in a separate page, I'm getting results for an autocomplete search box. The select boxes are for filters. Naturally, if the user selects a filter, I don't want to suggest items that are no longer valid. I'm looking for the keys in the ProcessRequest method of the page that contains autocomplete info.
public override void ProcessRequest(HttpContext context)
{
string respString;
string qsKey = "q";
Customer searchCust = Session[Data.Selected_Customer] as Customer;
Dictionary<string, string> qsDict = context.Request.QueryString.ToDictionary(qsKey);
Shouldn't I get the results (for instance '&ID=foo' on the last line # context.Request.QueryString?
If you want the actual selected item itself:
$("#ID option:selected");
are you sure that 'ID' is really the id of the select box ? been awhile since i used asp.net but i remember it mucked with identifiers a lot
I use the code (below) to manipulate an ASP.NET generated select box. Within the code I obtain the value of the original select box (item). Also consider using the .text() function.
var setValue = function(item){
//if value isn't already selected, postback
if(input.value != item.text())
if(select.attr('onchange'))
eval(select[0].attributes['onchange'].nodeValue);
//set input box value
$(input).val(item.text());
$(input).removeClass('empty');
//select original ASP.NET select value (hidden)
select.val(item.text());
$(lookup).hide();
//show type if present
$('.selectType').show();
};
Hope this helps.
I have a page that does ASP.NET ajax postbacks using UpdatePanels. In some javascript, I set up some objects in the window.onload event, which works great. When I do a postback though, it seems like my objects are messed up.
One object which was receiving events from a table, is no longer receiving the events. I also had a case where objects which has local references to buttons wouldn't be able to update them. Here's the button javascript that was getting messed up:
function EditItemPage(clientId)
{
this.saveButton = $get(clientId + ""_{2}"")
this.publishButton = $get(clientId + ""_{3}"")
this.exitButton = $get(clientId + ""_{4}"")
EditItemPage.prototype.GoDirty = function()
{
//it works if i add these, but i'd rather not have to.
this.saveButton = $get(clientId + ""_{2}"")
this.publishButton = $get(clientId + ""_{3}"")
this.exitButton = $get(clientId + ""_{4}"")
this.saveButton.disabled = false;
this.publishButton.value = 'Save and Publish';
this.exitButton.value = 'Discard changes and Exit';
}
}
So after I do a postback, the button references are messed up unless i reset them as I did in the GoDirty() function.
Any insight?
The this keyword (special variable) changes based on what function is calling it. Basically, it's an issue of scope. You need to either do a closure around the function which is being called on the ajax response, OR put what you need into the global scope, OR do what you are doing (which you don't like).
Writing the closure is the "right" way.
You may be familiar with the way the this variable changes scope based on events for form inputs. For a textbox, if you use the onblur event, the this refers to the textarea which just lost focus.
See this question for an example of how to do the closure.
This is also another good resource.
(I'm sure I could copy and paste the examples in here for you, but that seems redundant)