Today I try to use route name in my MVC
string url = urlHelper.RouteUrl(routeName, routeValues);
Yes it don't work because it didn't find my route name
A route named 'Index' could not be found in the route collection.
Only route name "Default" i can use so what the point?
to use route name work you must map like
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Vsaving", action = "Index", id = "" } // Parameter defaults
in Global.aspx ( I still don't test this )
another way use Action instead Route like this
RedirectToAction(string actionName, string controllerName);
compare with
RedirectToRoute(string routeName); If want to go "Index2" or something you must routes.MapRoute before
This is clear?
วันอังคารที่ 30 มีนาคม พ.ศ. 2553
วันจันทร์ที่ 29 มีนาคม พ.ศ. 2553
Use Membership to get UserId
User.Identity have name but where userId
Here how to get that
MembershipUser CurrentUser = Membership.GetUser( User.Identity.Name ); // or use Membership.GetUser();
int userID = int.parce( CurrentUser.ProviderUserKey.ToString() );
by the way this mean when you want userID you must connect database so
check on this article for use other way to keep user
http://www.eggheadcafe.com/tutorials/aspnet/33d4018a-03cf-48aa-9b68-82ba27aa6af9/forms-auth-membership-r.aspx
and some customize provider will help this job done.
http://weblogs.asp.net/scottgu/archive/2006/04/13/442772.aspx
Here how to get that
MembershipUser CurrentUser = Membership.GetUser( User.Identity.Name ); // or use Membership.GetUser();
int userID = int.parce( CurrentUser.ProviderUserKey.ToString() );
by the way this mean when you want userID you must connect database so
check on this article for use other way to keep user
http://www.eggheadcafe.com/tutorials/aspnet/33d4018a-03cf-48aa-9b68-82ba27aa6af9/forms-auth-membership-r.aspx
and some customize provider will help this job done.
http://weblogs.asp.net/scottgu/archive/2006/04/13/442772.aspx
วันอาทิตย์ที่ 28 มีนาคม พ.ศ. 2553
jQuery and error "$ is not define"
To day I use Jquery in ASP.NET MVC and can't make it work.
It's always show java script error about "$ is not defined"
Yes after search and found a call wrong path for Include my jQuery script
and my problem now is confuse about relative path for jquery in my master page
and finally anything solve by
Url.Content ("~/Scripts/jquery-1.3.2.min.js")
Used this instead of
../../Scripts/jquery-1.3.2.min.js
Yes I don't include full code here because Google don't support code html for example with out encoding it myself.
I will find another block for do that.
Yes this will solve problem with css too.
It's always show java script error about "$ is not defined"
Yes after search and found a call wrong path for Include my jQuery script
and my problem now is confuse about relative path for jquery in my master page
and finally anything solve by
Url.Content ("~/Scripts/jquery-1.3.2.min.js")
Used this instead of
../../Scripts/jquery-1.3.2.min.js
Yes I don't include full code here because Google don't support code html for example with out encoding it myself.
I will find another block for do that.
Yes this will solve problem with css too.
วันพฤหัสบดีที่ 25 มีนาคม พ.ศ. 2553
Add Header link in C# Code Behind and Front
use HtmlHead and HtmlLink for this job
HtmlHead header = (HtmlHead) Page.Header;
HtmlLink link = new HtmlLink();
link.Attributes.Add( "href", Page.ResolveClientUrl( "~/App_Themes/Default/Default.css" ) );
link.Attributes.Add( "type", "text/css");
link.Attributes.Add( "rel", "stylesheet");
header.Controls.Add(link);
HtmlHead header = (HtmlHead) Page.Header;
HtmlLink link = new HtmlLink();
link.Attributes.Add( "href", Page.ResolveClientUrl( "~/App_Themes/Default/Default.css" ) );
link.Attributes.Add( "type", "text/css");
link.Attributes.Add( "rel", "stylesheet");
header.Controls.Add(link);
วันพุธที่ 24 มีนาคม พ.ศ. 2553
Kaspersky 2010 and MSN file transfer
"C:\Program Files\Kaspersky Lab\Kaspersky Internet Security 2010\avp.exe" scan
use this command in file transfer to receive or send file.
use this command in file transfer to receive or send file.
สมัครสมาชิก:
บทความ (Atom)