WebMatrix :: Razor Doesn't Get Checked Value
Aug 28, 2010I have a problem with razor in a checkbox. It does not get a checked value. Here is the code:
[Code]....
I have a problem with razor in a checkbox. It does not get a checked value. Here is the code:
[Code]....
I can not get the _PageStart.cshtml to work for my layout senario. I would prefer to use _PageStart to define a layout for all files in each folder. Each folder represents a different app feature that will contain different layouts.
Until I find a work about I had to copy and past the Layout ="~/folder/_PageStart.cshtml into each page of the folder to get the different layouts to work.
_PageStart isn't being recognized at all as the folders page start. Is there a web config setting missing? The docs aren't fully extensive yet for all Razor related info and I couldn't find anyone discussing this problem via search results.
In order to keep close to code once and separation I need to use the _PageStart.cshtml method rather than code a line in each page in the folder.
On win7 using both webmatrix and vs2010 web engines. Neither recognizes _PageStart.cshtml but hard coding into each file works.
My hosting company states they support .net and razor. However after uploading my website made with webmatrix and razor *.cshtml pages. When i visit my website all i get is 404.17 error messages. As an testcase i decided to add an standard .aspx page. Visiting that page gives the same 404.17 error message :-(
.
According to my webhoster my web.config is wrong. However that one is generated by webmatrix. Besides my *.cshtml *.aspx a lot of files and directories are added to the bin folder. What can i check and what should my hosting provider check. When using the check compatibility the asp.net version is shown as unknown? My hosting provider claims my site is running asp.net 4.0 in integrated mode and that should be enough.
i would like to write Rss feed page using the razer syntax in webmatrix and i am facing probem in xml formatting
View 3 RepliesIn Windows Forms I can create a class file called 'Authentication.cs' with the following code:
public class Authentication
{
public string Name;
internal bool Authenticate()
{
bool i = false;
if (Name == "Jason")
{
i = true;
}
return i;
}
}
In WebMatrix, I can insert a new Class file, called 'Authentication.cs', and insert the above code. And in my default.cshtml file, I do this:.........................
How would I retrieve IP address with Razor? I have tried @Request.UserHostAddress and it returned ::1 to me instead of an IP adress. I am running this of course under IIS8 that came with webmatrix.
View 3 RepliesI am developing a project that has a DateTime field.
In it I'm using jQuery for the user to select the date format 'dd/MM/yyyy' taking into account that the date is not a required field.
How do you do to save DateTime fields not required in WebMatrix and Razor?
I was trying to do something like this:
I put only the code which I think is important to complete the code can be found here
@{
//Get data
string TaskForecastCompletion= Request["txtForecastCompletion"];
string TaskCompletedIn= Request["txtCompletedIn"];
DateTime dtForecastCompletion = default(DateTime);
[Code]....
How can I acces the subdomain from the razor syntax.forum.mysite.com ==> forumwww.mysite.com ==> www
View 8 RepliesI'm learning razor syntax, using the startersite in WebMatrix and trying to display some data from a table. I want to select only the data from the logged in user, so in effect want to say
...WHERE UserId =@WebSecurity.CurrentUserId";but that doesn't work.
Using the @0 method doesn't work for me either - I get an 'A parameter is missing. [ Parameter ordinal = 1 ]' error.
Do I have to set a variable then use the @0 / @1 / @whichever way? If so - what's wrong with this code?
@{
//Is the user logged in?
WebSecurity.RequireAuthenticatedUser(); [code]...
now if i want to iterate through the object it doesnt seems to work :
var myobject = new{param1 = "value1" , param2 = "value2" }
foreach(var i in myobject){
@i.Value
@i.Key
}
doesnt work.
While it has gnerally been advocated to separate code from mark up and all that, with the razor syntax and webmatrix all that is not valid anymore, I think. WebMatrix encourages code and mark up in the same page! So what is the best practice as far as code and mark up is concerned.
View 6 RepliesWhen you do introduce intellisense and colorization to the razor editor, what about allowing the developer to choose the schema that it verifies against? If it could by default use a flavour of HTML, but optionally allow the dev to reference an arbitary XSD file (as supportted by the XML text editor). It could result in a very flexible experience that supports using ASP.Net MVC as a web service returning XML.
anybody tell me how to create WebService like asmx on razor syntax.
View 6 RepliesFollowing this tutorial: [URL]
Under "Sending a File Using Email" section what exactly is the code trying to do.
1: The SendFile.cshtml does not have any option to select file.
2: ProcessFile.cshtml is running fine. I am getting the email but no attachement.
I tried changing fileAttachment input to type="file" but not file is being sent to my email. I just get the message send in body.
Question: How exactly this file attachment works using Email Helper in WebPages.
Is it possible to somehow output some content based upon some conditional check in Razor? If not, I hope this possibility will be added in the future. What I want to do is the following:
[Code]....
It's great that Razor HTML encodes by default. However, many times I have HTML in a database and want to display it literally on a page. In WebForms 4, we can use <%= %> and <%: %> to choose between encoding options. Raven's syntax is currently @(new HtmlString(Model.Greeting)).
add a shorter syntax to Razor. Something like @=Model.Greeting or @@Model.Greeting, or something else.
I am trying to achive the following using Razor syntax, notice the lines in bold. I want to insert a '<tr>' tag based on a precondition.
[Code]....
However when I run this I get the following error Encountered end tag "tr" with no matching start tag. Are your start/end tags properly balanced?
I have created a site with webmatrix. When I try to run it, it says it cannot because it needs admin right to make the connection to port.I tried to run Webmatrix with admin right it doesn't change anything.
View 2 RepliesI've been told by my host that I need to enable FullTrust in my webmatrix website because I keep getting an error. (BUT, I have used a different host, and everything on my site works perfectly with them without modification). Anyway, I used the code my host suppllies in their KB, but that just generates a different error. So I looked up full trust on google and used about 5 different code samples to enable full trust but they all generate errors! even the ones on MSDN. And googling "Full Trust WebMatrix" doesn't really bring anything helpful either.
How can I successfully add full trust to a web.config file that is made using WebMatrix?
[Code]....
I've found a Webmatrix help article that says MS Webmatrix "publishes the (SQL Server or MySQL) database by creating scripts that run in a database that has been created for you by your hosting provider." That is wonderful, except I can't get it to work when I'm trying to publish a MySQL database (backing wordpress) through FTP (my hosting provider does not support 'web deploy'). Again, no problem, since it is already documented that " FTP protocols cannot be used to publish MySQL database. " But this does not excuse Webmatrix from generating MySQL database install scripts for me. During the publishing step, no database install script is generated - at least that I can tell - and there is no manual option to create a database export / backup / install script.
In short, as Webmatrix goes, I'm dead in the water trying to get my database uploaded to my hosting provider. Does anyone know the trick to force Webmatrix to create the MySQL database install scripts on my local box? Once created, I can take-over the upload and install process.
I'm wondering if it is possible to include Microsoft.Data.Entity.CTP.dll reference to WebMatrix site and if the Compact edition of the database would support it? I'd kinda love use something like
code-first development in my WebMatrix project. I think is even easier than writing SQL-s into the code...
I'm just starting out with WebMatrix and would like to know how to style a @Html.TextBox("email") and @Html.Password("password") control? I've tried (in my CSS file):
.email{
/* styles here */
}
.password{
/* styles here */
}
But that has no effect at all. How can we style these types of controls?
I started the Bakery site demo...everything runs fine on my local machine.When I publish the site to production server in w2k8r2+iis7.5 and with .net 4.0 (integrate) pool, my bakery apps not able to connect to the .sdf file.
Error I got is :
Connection string "bakery" was not found. Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: Connection string "bakery" was not found.
Source Error:
Line 2: Layout = "_SiteLayout.cshtml";
Line 3:
Line 4: FacebookSocialPlugins.Initialize("[xxx]", "[xxx]","bakery");
Line 5:
Line 6: }
Stack Trace:
[InvalidOperationException: Connection string "bakery" was not found.]
WebMatrix.Data.Database.OpenNamedConnection(String name, IConfigurationManager configurationManager) +132
WebMatrix.Data.Database.Open(String name) +42
System.Web.WebPages.DatabaseConnectionInfo.Connect() +43
System.Web.WebPages.SimpleMembershipProvider.CreateTablesIfNeeded() +42
System.Web.WebPages.WebSecurity.InitializeMembershipProvider(SimpleMembershipProvider sMembership, DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean createTables) +70
System.Web.WebPages.WebSecurity.InitializeProviders(DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +51
System.Web.WebPages.WebSecurity.InitializeDatabaseConnection(String connectionStringName, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +52
FacebookSocialPlugins.InitializeMembershipProviderIfNeeded() +54
FacebookSocialPlugins.Initialize(String appId, String appSecret, String membershipDbName) +171
ASP._PageStart_cshtml.Execute() in d:xxxakery\_PageStart.cshtml:4
System.Web.WebPages.StartPage.ExecutePageHierarchy() +15
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +33
System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContext context) +207
I know we can use the HTML helpers, but how about the strongly typed one's?
Html.LabelFor()
I struggle with publishing 2 databases from WebMatrix using WebDeploy. On Publish settings screen I specify 2 different connection strings, but on Publish Compatibility screen Database names in both destination connection strings are equal. When I return to settings screen, original value is replaced there as well.
How destination server connection strings are evaluated? Here are connection strings from the root web.config file, which are set by hidden parameters in my parameters.xml:
<connectionStrings>
<add connectionString="Server=(local);Database=xxx;Uid=xxx;Pwd=xxx" name="xxx" providerName="System.Data.SqlClient" />
<add connectionString="Server=(local);Database=xxx2;Uid=xxx;Pwd=xxx" name="xxx" providerName="System.Data.SqlClient" />
</connectionStrings>