I have several Razor functions at the beginning of my _SiteLayout.cshtml
file that I thought would be accessible by pages using it for their layout. However it doesn't seem to work that way... Is there any way for other pages to utilize them?
Edit:
Here's an example of one of the functions. If I define the function like you mentioned will I be able to call it by using it's name? Ex. SaveQuestion(3, someVariableHere)
public void SaveQuestion(int QID, string A)
{
if (A != "")
{
var db = Database.Open("DB2");
var save = "INSERT INTO QuestionnaireData (QuestionID, ID, Answer) VALUES (@0, @1, @2)";
db.Execute(save, QID, WebSecurity.CurrentUserId, A);
}
}
Something like:
public static class GlobalFunctions
{
public void SaveQuestion(int QID, string A)
{
if (A != "")
{
var db = Database.Open("DB2");
var save = "INSERT INTO QuestionnaireData (QuestionID, ID, Answer) VALUES (@0, @1, @2)";
db.Execute(save, QID, WebSecurity.CurrentUserId, A);
}
}
}
And then something like GlobalFunctions.SaveQuestion(3, someVariableHere)
to call it?