Closed
Description
I would like blazor to provide better management and handler for querystring of current page url
[FromQuery] attribute for two way binding
It should allow binding to a field and/or property, so that it would always binded with query string with the same name as the property
@code {
[FromQuery]
int size = 0;
[FromQuery("queryName")]
int internalName = 0;
[FromQuery("date","yyyyMMddHHmmss")] // with format?
DateTimeOffset internalName = DateTimeOffset.Now;
}
NavigationManager
Should provide API for URI manipulation and history
public static Uri WithQuery(this Uri uri,string name,string value)
{
// anything better with the same result?
var query = HttpUtility.ParseQueryString(uri.Query);
query[name] = value;
return new UriBuilder(uri){ Query = query.ToString() }.Uri;
}
void GetAbsoluteUri(this NavigationManager manager) => manager.ToAbsoluteUri(manager.Uri);
// navigateTo(uri.WithQuery())
void SetQuery(this NavigationManager manager,string name,object value);
void SetQuery(this NavigationManager manager,params (string name,object value)[] values);
string GetQuery(this NavigationManager manager,string name);
/////////
// localhost/?q=0 >>> localhost/?q=1
navManager.SetQuery("q",1);
navManager.SetQuery("q",int.Parse(navManager.GetQuery("q")) + 1);
Underlyingly should just call history.pushState
if available
Metadata
Metadata
Assignees
Labels
This issue has been fixedThis issue requires design work before implementating.This issue impacts only small number of customersIncludes: Blazor, Razor ComponentsThis issue represents an ask for new feature or an enhancement to an existing oneFeatures related to the built in components we ship or could ship in the futureThis label is used by an internal tool