Dec 20

Rewriting urls in Asp.Net is not a complicated thing if you remember some basic steps:
1. Any request will first go to Application_BeginRequest from Global.asax
2. Your online store must be designed in an easy way:
- categories must be unique by name
- subcategories must be unique by name in the same category (The pair category-subcategory must be unique)
In this way you can have as many levels as you want.

Using this advices, you will have a function that helps your users navigate through levels of categories.
protected void Application_BeginRequest(Object sender, EventArgs e)
{

string fullOrigionalpath = Request.Url.ToString();
string filePath = Request.FilePath.ToString();

if (filePath.ToLower().Contains(“sitemap.html”))
{

//if you have a custom sitemap
HttpContext.Current.RewritePath(Generics.HTTP.AppPath + “Sitemap.aspx”, false);

}
//Generics.Constants.Page_EXT in this case is “.html”
filePath = filePath.Replace(Generics.Constants.Page_EXT, string.Empty);
string originalFilePath = filePath;

string path = Generics.HTTP.AppPath;

//HERE you add your code
//first you can check if filePath  contains a product id. In this case:

path+=”Products.aspx?id_products=”+id_product;

//if filePath is not a product page, than you check your categories
Category categ=Utility.GetCAtegoryByFriendlyName(filePath);
path+=”Category.aspx?id_category=”+categ.id;

//finally you need to rewrite path as needed
HttpContext.Current.RewritePath(path, false);

}

Dec 20

Let’s say we have something like the next scenario:
1. We have a popup window for editing a record.
2. We need to select a value from a complex list of records, so we need another popup for this select.

Problem:
Our second popup is bigger then the first one, so we need to open it from our main page.
By now, we manage to do this really easy. The main issue is when trying to pass the selected value from the second popup to first one. Remeber that we opened it from the main page.

Solution:

In the first popup we will have a function for opening the second popup.
In this function we set a var childPage from the main page as a reference to our first popup.

function openPopup(){

window.parent.setHiddenPageChild(window);
window.parent.OpenModalWindow(params);


}

On the main page we have the setHiddenPageChild function

var childPage;
function setHiddenPageChild(child){

childPage=child;

}

and setRecordFromResponse function that will pass the selected value from the second popup to the first one.
This function will be called from the second popup like this: window.parent.setRecordFromResponse(response)

function setRecordFromResponse(response){

childPage.UseSelectedRecord(response);
//childPage served us well, so we will let it retire
childPage=null;

}

Response is the value selected in the second popup. It can be an id, a value or an object.
Now we use childPage that was initialized at a previous step. This is how we can have access to the functions of the first popup

Dec 2

Some days ago I run into the following problem with jQuery’s datetime picker.

I have a form that contain a input field that I populate with a date/time picker.  If you populate the form on the server with some default values, the jQuery’s hidden fields wont get set unless you do some action on the calendar.

The  solution  is to add inline:true to its options like this:

$(“#myDate”).datepicker({

inline: true,
dateFormat: ‘yy-mm-dd’

});

Powered By Wordpress - Theme Provided By Wordpress Theme - Credit Loan