Starts in:
0 DAY
11 HRS
55 MIN
39 SEC
Starts in:
0 D
11 H
55 M
39 S
Open Closed

Instead of opening edit popup modal screen , how to redirect to page #1765


User avatar
0
Shoba24 created
  • ABP Framework version: v4.4
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

For new product screen, we didn't use popup modal.we have requirements of redirecting to another page.For that we use anchor tag href.

Now for edit product screen, how to redirect to page instead of opening popup modal


12 Answer(s)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi @Shoba24, you can simply use window.location.href or window.location.replace("your-url") and if you want to pass a parameter to that page, use data parameter of the action function.

    action: function(data) {
        //...
        window.location.href = "/product/ + data.record.product.id;
    }
    
  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

  • User Avatar
    0
    Shoba24 created

    Hi,

    in edit screen ,we have cancel and save button.After clicking save button,we want to redirect to index page.

    we tried to redirect in OnPost method but not working.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi @Shoba24, Can you share your *.cshtml.cs file?

  • User Avatar
    0
    Shoba24 created

    Hi EngincanV,

    we want to validate and display corresponding error message on this create and edit page.

    In pop up modal, we used to validate like this

    and its working fine in pop up modal.

    But in create/edit page ,it doesn't work well..

    We get error like this

    we need to display like this

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi @Shoba24, I think you need to use the UserFriendlyException (https://docs.abp.io/en/abp/4.4/Exception-Handling#user-friendly-exception).

  • User Avatar
    0
    Shoba24 created

    Hi, we use this user friendly exception.Still got error like this

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, can you share the OnPost method of your CreateModal.cshtml file?

  • User Avatar
    0
    Shoba24 created
    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");
    }
    
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    we need to display like this

    Hi, sorry for the misunderstanding but you can not trigger a modal like in the above photo. (if you want to trigger it, you need to call the method that throws an exception on the js side).

    • You can use the Alerts to show errors on UI.
    public async Task <IActionResult> OnPostAsync() 
    {
        try 
        {
           //your code
        }
        catch(Exception ex) 
        {
           Alerts.Danger(ex.Message); //for other alert types see https://docs.abp.io/en/abp/4.4/UI/AspNetCore/Page-Alerts#alert-types
        }
        
        return Redirect("/PurchaseOrders");
    }
    
  • User Avatar
    0
    Shoba24 created

    Hi EngincanV,

    This is not working.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi @Shoba24, you also need to add return Page(); line after the Alerts.Danger(ex.Message); to show the error in your UI.

    public async Task <IActionResult> OnPostAsync() 
    {
        try 
        {
           //your code
        }
        catch(Exception ex) 
        {
           Alerts.Danger(ex.Message); 
           return Page(); //show alert on the page
        }
        
        return Redirect("/PurchaseOrders");
    }
    

    For other alert types see https://docs.abp.io/en/abp/4.4/UI/AspNetCore/Page-Alerts#alert-types

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