Starts in:
2 DAYS
2 HRS
8 MIN
56 SEC
Starts in:
2 D
2 H
8 M
56 S
Open Closed

Display success msg on form submit #2246


User avatar
0
Shoba24 created

we didn't use pop up modal.we have requirements of displaying success msg and redirect to index page when submitting form successfully.since we r not using pop up modal ,couldn't use javascript to display abp.msg.success.

OnPost(.CS)

public async Task <IActionResult> OnPostAsync() {
	var files = Documents;
	var purchaseOrder = PurchaseOrder;
	purchaseOrder.StatusName = _settings.StatusSetting.Open;
	//Validate
	var validateResult = purchaseOrder.Validate();
	if (!validateResult.IsSuccess) {
		throw new UserFriendlyException("Model is not valid");
	}

	foreach(var fileExtension in files) {
		if (!fileExtension.ContentType.Contains("pdf") && !fileExtension.ContentType.Contains("doc") && !fileExtension.ContentType.Contains("docx") && !fileExtension.ContentType.Contains("msword")) {
			throw new UserFriendlyException("File is not in valid format");
		}
	}
	var result = await _purchaseOrdersAppService.CreateAsync(PurchaseOrder);

	if (files != null && files.Count() > 0) {
		foreach(var file in files) {
			var documentsPath = _blobStorage.UplodPurchaseOrderFile(file, result.Id).Result;
			var documentInput = new DocumentCreateDto {
				FileName = file.FileName,
				FilePath = documentsPath,
				FileSize = (int) file.Length,
				FileType = file.ContentType,
				RecordId = result.Id,
				TypeName = _settings.DocTypeSetting.PurchaseOrder
			};
			await _documentAppService.CreateAsync(documentInput);
		}
	}
	return Redirect("/PurchaseOrders");
}

13 Answer(s)
  • User Avatar
    0
    yekalkan created
    Support Team Fullstack Developer

    Hi @Shoba24,

    Do you want to display the success message in the current page or redirected page?

  • User Avatar
    0
    Shoba24 created

    Hi yekalkan,

    Whatever ok.I just want to notify user that form saved successfully

  • User Avatar
    0
    yekalkan created
    Support Team Fullstack Developer

    Does /PurchaseOrders include a javascript file? You can use abp.message.success there maybe.

  • User Avatar
    0
    Shoba24 created

    How can we use abp.message.success for page? we know that for popup modal ,we can use like this

    createModal.onResult(function () { abp.message.success('Payment Term have been successfully saved!'); }

  • User Avatar
    0
    yekalkan created
    Support Team Fullstack Developer

    You need to simple type abp.message.success('Payment Term have been successfully saved!'); in your javascript file and it will be shown after the page is loaded.

  • User Avatar
    0
    Shoba24 created

    in which js file? create or edit or index?

    If its index.js , success msg showing immediately while clicking purchase order (Even without going to new create page).

    I dont understand what u're trying to say?

  • User Avatar
    0
    yekalkan created
    Support Team Fullstack Developer

    I'm mentioning the page that current page redirects. (/PurchaseOrders)

  • User Avatar
    0
    Shoba24 created

    that /PurchaseOrders is index page(Datatable)

    Here when clicking new purchase order button,it goes to another page.After entering data and click submit need to show success msg and redirect to /PurchaseOrders

  • User Avatar
    0
    yekalkan created
    Support Team Fullstack Developer

    I see. Then you can place abp.message.success in index page and show when user returns from NewPurchase page. (You can use QueryString to trigger the success message).

  • User Avatar
    0
    Shoba24 created

    can u please explain me in detail?

  • User Avatar
    0
    Shoba24 created

    Hi @yekalkan,

    I tried as u said.It works fine but i'm facing some issue.

    I updated one purchase order and it returns to index page with querystring.

    And again ,i click edit button to update purchase order.It goes edit screen.From that edit screen,if i click back button to come to index page ,that success msg got triggered bcz of query string.

    How to solve this issue?

  • User Avatar
    0
    Shoba24 created

    Hi,

    Any solution?

  • User Avatar
    0
    yekalkan created
    Support Team Fullstack Developer

    Hi,

    The problem you encounter is unrelated to our product.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06