RSS

A Message Board, Guestbook, or Poll hosted for your website.
Iron Speed Technical Forums

Register Login New Posts Chat
 
Iron Speed > Forums > Code Repository V6.X > How to change URL dynamically in Save method based on dynamic value.
 
Username:  
Password:  
 
   
 


Thread Tools Search This Thread 
Reply
 
Author Comment
 
vijaym
Registered: 11/05/09
Posts: 6

    11/05/09 at 05:53 AMReply with quote#1

Issue:
I need to check if record already exists. If record already exists then show error message on add screen and do not redirct. If recrod does not exists then, save record and redirect to showtable screen.
 
I have added one property in "BaseApplicationPage.IsDuplicateEntry". which i set true/false in following method of
"XXXRecordControl:BaseClientKPIsRecordControl"
by overriding SaveData() method.
 
Till here, everything works fine.
 
But issue is url is hard coded inside save method in local variable to method.
 
Now, if i write some custom code to set URL based on "IsDuplicateEntry" property value, which get overrite by iron speed designer. because this method is under " Section 2: Do not modify this section."
 
 
---------------------------
public
void SaveButton_Click_Base(object sender, EventArgs args)

{

string url = @"../ClientKPIs/ShowClientKPIsTable.aspx";

// The redirect URL is set on the Properties, Bindings.// The ModifyRedirectURL call resolves the parameters before the// Response.Redirect redirects the page to the URL. // Any code after the Response.Redirect call will not be executed, since the page is

// redirected to the URL.

bool shouldRedirect = true;

string TargetKey;

string tk = null;

TargetKey = tk;

try {

// Enclose all database retrieval/update code within a Transaction boundary

DbUtils.StartTransaction();

if (!this.IsPageRefresh)

{

this.SaveData();

}

url = this.ModifyRedirectUrl(url, "",false);

this.CommitTransaction(sender);

} catch (Exception ex) {

// Upon error, rollback the transaction

this.RollBackTransaction(sender);

shouldRedirect = false;

this.ErrorOnPage = true;

// Report the error message to the end user

BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "BUTTON_CLICK_MESSAGE", ex.Message);

} finally {

DbUtils.EndTransaction();

}

if (shouldRedirect) {

this.ShouldSaveControlsToSession = true;

this.Response.Redirect(url);

}

else if (TargetKey != null && !shouldRedirect){

this.ShouldSaveControlsToSession = true ;

this.CloseWindow(true);

}

}
----------------------


1. Any guess or hint to fix this issue.
2. Why redirect URLs are hard coded into the class methods, instead it should be read from config file or common class with const string variables.

Thank you.
Vijay.

akeshgupta
Avatar / Picture

Iron Speed MVP
Consulting Organization

Registered: 04/25/04
Posts: 4,244

    11/05/09 at 06:07 AMReply with quote#2

Hello:

What you can do is to override the Validate event and do your validation before attempting to save the record.  It should do the trick.

You can look at code customization for an example on Validation.

HTH,


__________________
Akesh Gupta
Iron Speed Designer MVP
Enterprise Solutions Architect
ExecuTrain of Long Island (http://www.etli.com)
Light Speed Solutions (http://www.lightspeedsolutions.com)

If I rest, I will rust ! Let's share the knowledge !
Previous Thread | Next Thread
Reply

  Bookmarks  
Digg Diggdel.icio.us del.icio.usStumbleUpon StumbleUponGoogle Google

Download Iron Speed Designer

Privacy Statement