I have a typical ASP.NET web form application. It has about 20 separate user controls (.ascx files), each one containing a DetailsView control. One of the requirements of this application is that there needs to be a single Edit, Update, and Cancel link outside of those user-controls, which, when clicked, will cause each of those DetailsView objects to go into the correct mode, Edit or ReadOnly, and, if Update was clicked, do an appropriate database update. In other words, clicking that "global" link has to programmatically fire the client-side click for each of those corresponding links that you get "for free" when you create a DetailsView or GridView. I've tried copying the actual __doPostBack event that gets invoked when you do use one of those "internal" links, assigning it to a string, doing a Page.ClientScript.RegisterScriptBlock, then doing a LinkName.Attributes.Add("onclick", "script_string_name") -- but I just can't get it to work. What is the correct way to accomplish this?
You can use the asp:linkbutton control to do this.
Related
As the title states, I need to filter results of an associated view based on a record's field value and user permissions.
I've used some Javascript to achieve this whenever the iFrame loads, but if the user switches to a different view, my Javascript is not called and the filtered records come back. I've tried to implement an event listener for various changes within the iFrame, but haven't been able to get what I need. I've gotten onclick to call my function whenever the user opens the view dropdown, but I need it to call whenever they actually switch views.
Am I over complicating this and there's a native way to do this? Or does anyone know how to detect changes within an iFrame?
Unfortunately there’s no native config to do it by OOB. I recommend these.
Don’t rely on associated view, as the name suggests it’s for seeing all the associated records. Remove navigation item in Form editor to remove them if you don’t want your users to see it
Use Subgrid for all your different needs, but not with view switcher, as again you will get roadblock of view switch triggers, etc. also this is going to be unsupported approach to rig the FetchXml with your custom filters
Custom HTML with grid is better or even PCF control of your own to take query & filters
Plugin on RetrieveMultiple can be used in worst cases
I want to add a customized button in oracle apex interactive grid to allow users to go back to the previous page. Can someone explain how I can do this in javascript? Thanks
Without javascript (recommended):
Create your button, let's say BTN_PREVIOUS, and a hidden page item, P1_PREVIOUS_PAGE
Create a new branch:
Point: After Porcessing
Behavior Type: Page Identified by Item (Show only)
Item: Select your hidden item created on step 1 (P1_PREVIOUS_PAGE)
Server-side Condition: When Button Pressed, BTN_PREVIOUS
Now for every page that calls this one, you have to set the item P1_PREVIOUS_PAGE with the number of the calling page. There's innumerable ways to to this (through declarative list entries, URL, javascript), I recommend you to read https://docs.oracle.com/cd/E59726_01/doc.50/e39147/concept_url.htm
Obs: if you do the steps above, make sure that every other process, computation and branches have a server side condition, because this method relies on submitting the page and you don't want your "Previous" button triggering any other logic that you have already created.
With javascript:
Create your button, let's say BTN_PREVIOUS;
Create a dynamic action
When: Event: Click
Selection Type: Button
Button: BTN_PREVIOUS
Inside the dynamic action create a true action:
Action: Execute JavaScript code
Code: history.back()
Although the javascript way is simpler, it's always preferable to use what the tool (APEX) has to offer.
You can use history.back() or if you want to go multiple steps back history.go(-2)
I'm developing a kind of online store in which adding items to carts are carried out by an Ajax method. I'm using ASP.NET MVC and in my Razor view engine I Require to have many submit buttons with the same ID (for some reasons) but with different names to distinguish them problematically. These buttons are used to fire the Ajax method at different areas in the same page. When they are clicked, they set some value to a hidden submit button (the ones that share the same ID) and then fire them. I need to fire these button based on their names, for example
//Instrad of
$("#ID").trigger("Click")
//I trigger click them by their `name` attribute.
I know how to get the values or other attributes of an element by name, but so far I have no clue on how to trigger a button by name. So I wanna know if that's possible at all and how it can be done.
Try below
$("button[name='btnName']").trigger("Click");
I have a web page (all done in client side code) where users can add certain page elements dynamically through different buttons.
For example, they can click a button called "Add Group" and input a group name. This will create a <div class="customGroup"> that displays the group as the "title" among some other buttons that let them add even more elements within that newly created <div>.
I want to be able to store what a user did and not have it lost if they do something like close & reopen the window or reload the page. So for example, if they add a group "Foo" and refresh the page, given that the page is all HTML/JavaScript, "Foo" is lost.
Is there some way I could record their actions and re-execute them using caching/cookies? Or do I need to do it some other way? Is this even possible?
I would suggest using localstorage to keep this data around, across windows opening and closing.
You can find out what the user clicks on by attaching an event listener to the elements you care about. The functions you pass in there can keep references to the clicked items by pushing them to an array. Then you can click them when you want to using .click().
As for text the users enter when the data is submitted, make sure its in localstorage as a string. On page load, you can put this data wherever you want to, so give it to an elements innerHTML and voila, you can reconstruct the page state.
I have a column that has 2 Categories, Done and Pending. I would like to Hide/Disable edit button once the user selects an item and if that item has a Status column of "Pending".
I would like to know how can this be done, whether in visual studio 2010 or ECMA Scripts.
I know this question is old but if someone still needs the answer:
Create a custom action in visual studio like this:
https://msdn.microsoft.com/en-us/library/office/ff408060(v=office.14).aspx
This hides the button you want, now you can set a condition via enabledscript parameter to choose in which case the button should be hidden:
Just add this code after </CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="HideEditRibbon"
CommandAction="javascript:return true;" EnabledScript="javascript:checkIfNeedsToBeHidden();" />
</CommandUIHandlers>
<CustomAction Id="yourJsReference" Location="ScriptLink" ScriptSrc="yourJsFile.js"></CustomAction>
If you need this in List-Ribbon, Edit and DisplayForm, you need to make 3 Custom Actions and change the Location-Part and maybe your js-code.
If you want to use an out of the box edit form then you're not going to do this with server side code; you'd need an entirely custom edit form to do that.
This means using Javascript on the edit page, which is fragile, and doesn't prevent users from saving the data if they know what they're doing.
The input field for every column will have a 'title' attribute with the column name. JQuery can find the element with title='column name' rather easily, so that's how you'll know if you need to hide the save button. The save button isn't quite as easy to get to. You could try getting the input with type=button and value=save.
If it's important to have actual security around this, so that no matter what someone can't edit an item in this state then you can use an event receiver on the ItemUpdating event. Just check the properties of the item and use the properties.Cancel = true; (or something like that) so that even if they disable your JavaScript and save the event anyway, it won't get saved. If you need help adding an event receiver or getting it working just ask.
Edit: In your comment that you say you just want to prevent access to the edit form entirely under certain conditions. For that, I'd make a new webpart/user control and add it to the edit page. In that section you can fetch the appropriate item (the ID of the item will be a query parameter) and see if the page should be 'viewable'. If not, then you can redirect to another page.
Another addition to the above would be attempting to edit the list view such that there is no edit link for certain items. This would be substantially harder, and I doubt it would even be possible (practically) with out of the box webparts. You would need to have an entirely custom list view page in order to control which items have links to an edit page. (Others feel free to correct me here.)