ASP.Net Load Data from another page - asp.net

i am facing one problem..
I have a page which has some templates related to user..
User use this template to send email..
User can have option to save this template and then he can load the saved templates...
What i want is on click on "Load Template" link. a new page appears which will display all the saved templates for logged in user. this page can contain grid. on select i want to close this load template page. and pass the text data back to previous page. which will display this template into text field. so that user can use saved templates.
How to do this using Asp.Net

You can do this using JavaScript, assuming the template selection window is opened with a call to window.open(). When the template is selected you can communicate and invoke methods (such as passing back the selected template ID) with code similar to this:
window.opener.templateSelected(selectedTemplateID);
window.close();
Here is information about window.opener

I believe that this may be what you're looking for. It's pretty straight forward and is in C#. It is done in .Net as opposed to client side JS.

Related

How to get the current page of Vmware clarity wizard?

We are using VMware clarity wizard to render wizard pages dynamically and we need to have custom logic to access the current page id/step id of the wizard for validation and other functionalities.
When trying to access page of the wizard, using pagesCollectionService and navService, we are getting the id's correctly for the first time e.g clr-wizard-page-0, clr-wizard-page-1 etc.
But the Problem is on click of cancel/submit from the wizard, the wizard id's are not getting reset, that is when we again open the same wizard the wizard page id's are in continuation to the previous id's
e.g :clr-wizard-page-4, clr-wizard-page-5 etc.
Is there a way by which we can access the page of the wizard by using any other property.
Note: Wizard pages are dynamically rendered using json
Attaching image : page id's that come up when we open the wizard for second time
enter image description here
Adding more information,
Please find the stackblitz link for more details:
https://clarity-light-theme-v013-phyhyk.stackblitz.io
Here we are rendering wizard pages, driven by config
For every wizard page we are displaying angular dynamic forms, where config contains all the information for the form fields .
Since is being called inside a for loop, we need to have a function where on click of next/back or on click of step of the wizard we should be able to validate the current form fields and store the current form fields value.
I have added (clrWizardCurrentPageChanged)="resetFormValidity()" and on every page change i am trying to retrieve the page id using wizard.currentPage.id, but the id's are not getting reset and when i access the multiple times, i am getting incremental id's : clr-wizard-page-4, clr-wizard-page-5 etc.
We are using the below versions :
"#clr/angular": "0.11.30",
"#clr/icons": "0.11.30",
"#clr/ui": "0.11.30",
Is there any other way where i can determine which page it is currently, so that i can compare that with config and continue with validation and form submission.
The Wizard has a property called currentPage which will tell you the current page. The public methods of the Wizard are at https://v2.clarity.design/wizards under the Wizard Deep Dive section, which might replace the need to inject and use the internal services which aren't meant to be used directly in applications (from what I understood in your message, an isolated demo would help greatly).
#ViewChild() wizard: ClrWizard;
get currentPage() {
return this.wizard.currentPage;
}

Adding lightbox (or something similar) to ASP.NET project

I need to implement some, let's call it "dialog" in some old ASP.NET project that I took over. It's huge project so I'm not allowed to implement new things.
I have a form on which user can attach up to 3 file attachments, enter some 10-15 fields, and when required fields are filled, submit button get's enabled.
What need to be done is press submit, wait for any possible response for server, and then display some sort of dialog, alert, lightbox which would display short summary and list of correctly uploaded files.
What would be the best approach to do this in ASP.NET?
Considering jQuery Lightbox is designed for overlaying images rather than HTML I would recommend using FancyBox or FaceBox instead.

Best way to notify user in asp.net webform

I would like to know what is the best way to do a notification in asp.net.
For example I have a form in which the user will provide some data. He then click the save button which call the save methode in my code behind.
In the save method I need to query the database to know if another related object exist. If not I need to notify the user that he will have to create the related object. This does not prevent the user from saving the parent object.
So I would like to do a modal popup telling the user : Hey after Im done saving your change, you will have to open another form and create the child object.
So should I create another NotificationWebform where the user will be redirect after the sava to notify him. It seems to be a "lot" of effort for a little notification. The best thing for me would be something like an alert in javascript.
Thanks!
Just put a lable on the page and display your message in that label after saving the data successfully to the database.
If it doesn't exist let him simply save it. If it already exists then just display that information to the user. Forget the JS alert and the modal pop-up; what if JS is disabled? Either way, just create success and failure messages/panels and display the appropriate one.
Normally, when I used Web Forms, I made all pages inherit from a custom class that extens Page class and inside this base Page class, I have 3 properties, one for SuccessMessage, ErrorMessage and NotificationMessage
Inside the Master Page, you can have 3 Labels and each one has a bootstrap css class according to its type, or maybe you can use toaster (https://github.com/CodeSeven), to show a nice popup like Outlook client.
In your button click event handler, you can simply set the NotificationMessage = "You have to blah blah blah ".
In the base Page class, you will check the value of each of these properties and if it is not empty then you will set the text of the corresponding Label and set Visible = true

asp.net mvc Upload File ajax

Hi ive got an mvc form with a fileupload functionality. Ive got an action that accepts an file and extracts thumbnails from it, after which the user can select the images and then proceed to submit the form. How can post the initial file via ajax, bearing in mind, this is not the final submission on the form and I want to retain user input. ie no postback
Thanks
I use the ajaxupload plugin for jQuery. Lots of sample code is provided on the site. From the site:
[The] plugin creates invisible file input on top of the button you provide, so when user clicks on your button the normal file selection window is shown. And after user selects a file, plugin submits form that contains file input to an iframe. So it isn’t true ajax upload, but brings same user experience.
Browsers don't allow the uploading of files via ajax. There are several good workarounds, however.

Running code/script as a result of a form submission in ASP.NET

An outside vendor did some html work for us, and I'm filling in the actual functionality. I have an issue that I need help with.
He created a simple html page that is opened as a modal pop-up. It contains a form with a few input fields and a submit button. On submitting, an email should be sent using info from the input fields.
I turned his simple html page into a simple aspx page, added runat=server to the form, and added the c# code inside script tags to create and send the email.
It technically works but has a big issue. After the information is submitted and the email is sent, the page (which is supposed to just be a modal pop-up type thing) gets reloaded, but it is now no longer a pop-up. It's reloaded as a standalone page.
So I'm trying to find out if there is a way to get the form to just execute those few lines of c# code on submission without reloading the form. I'm somewhat aware of cgi scripts, but from what I've read, that can be buggy with IIS and all. Plus I'd like to think I could get these few lines of code to run without creating a separate executable.
Any help is greatly appreciated.
If you don't want the page to reload after submission, you will need to use AJAX. that is alot more complicated. you would still need the submit.aspx, you cannot send email with javascript.
Code a redirect after the form submission, so instead of getting the same form back in the main document/page, you could get something like a blank page saying "Thanks for your submission!" or something of that nature.
Might be more simple to redirect the user to a result page using Respone.Redirect that displays some sort of "Your email has been sent" message, or even just redirect back to the base page.

Resources