While I was developing my asp.net website, I came across a scenario where I thought It would be cool if I could programmatically get a phone number from the database, and send that number to my VOIP Phone on my desk to actually start dialing the number for me and make the call. The VOIP 8x8 phone is connected to the computer via ethernet. The main ethernet cable goes from firewall to phone system, then an ethernet cable from phone to PC.

My next question about this if it can be done is, does this open up a vulnerability on the phone systems if code that can make a phone call is on my website? The site, as of now, does not use SSL but the page I want to execute this on is password protected.

I would like to be able to do this in vb.net if it is possible. I do not even know where I would start to try something like this, I tried to research a little and find other projects but I'm not coming up with anything helpful. I will gladly accept any bit of information that I can get.

I have a formview with a dropdown. My dropdown get's its list from a datasource. If I load the formview in view or edit mode, and that dropdown's value is something that isn't contained in the list, it will cause an error. How I can make it so I can view the formview by adding the value to the list without adding that value permanently? Thank you.

Why we still have beta references in VS2015 RTM [ASP.NET 5.0]

enter image description here

enter image description here

Inside a repeater I have an hyperlink in the item template.

<ItemTemplate>
<li>
<a runat="server" id="repLink">
<asp:Label runat="server" ID="lblSub"></asp:Label>    
</a>
</li>
</ItemTemplate>

in the code behind, OnItemDataBound I am accessing it with following code:

HyperLink repLink = (HyperLink) e.Item.FindControl("repLink");

Now I want to set the href for this hyperlink "repLink". But I cannot use .HRef ?

repLink.HRef = "https:\\google.com";

The above line gives me syntax error: "Cannot resolve symbol 'HRef'"

I even tried with Link but still the same error.

 Link repLink = (Link) e.Item.FindControl("repLink");

I'm working in an application which sends the mail from server. since smtp.send(msg) will take some time to communicate with the server. i had made the send code block in separate thread. It worked fine before, but after adding the timer control timer1( which was doing some code logic). The mail send was interrupted due to the following error :

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

Threading comes here..

void sendMail()
{
ThreadStart sendCreateMail = delegate() { Send(subject); };
Thread threadSendCreateMail = new Thread(sendCreateMail);
sendCreateMail.IsBackground = true;
sendCreateMail.Start();
timer1.Enabled = true;
}

net.mail code comes here....

protected void Send(string subject)
        {
            try
            {
                MailMessage mail = new MailMessage();
                SmtpClient smtp = new SmtpClient("smtp.office365.com");
                var credential = (System.Net.NetworkCredential)smtp.Credentials;
                string Username = credential.UserName;
                string password = credential.Password;
                mail.From = new MailAddress(Username);
                mail.To.Add(toMail);
                mail.Subject = "subject";

                mail.Body = "msg body";
                mail.IsBodyHtml = true;
                smtp.EnableSsl = true;
                smtp.Credentials = new System.Net.NetworkCredential(Username, password);
                smtp.Send(mail);
                }

I made a view Lista that adds a form in partial view with ajax to <tr id="myRow"></tr> in Lista.

In partial view I have:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BeekersInfo.Schemes.GrowerPickingList>" %>

<% using (Html.BeginForm("OnSave", "DailyPickingList"))
   {%>
    <%: Html.ValidationSummary(true)%>
        <td>
            <input type="submit" value="Save" />
        </td>
        <td>
            <%: Html.TextBoxFor(model => model.Remark, new { style = "width:110px; font-size:100%;" })%>
            <%: Html.ValidationMessageFor(model => model.Remark)%>
        </td>
<% } %>

End when I debug the function OnSave in dailypickinglist isn't called.

In html file it is shown:

<tr id="tr1"><form action="/DailyPickingList/OnSave" method="post"></form>
<td>
    <input type="submit" value="Save">
</td>
<td>
    <input id="Remark" name="Remark" style="width:110px; font-size:100%;" type="text" value="Testing app">
</td>

[HttpPost]
public PartialViewResult OnSave()//string rowID, string palletID)
{
   return PartialView("SingleRowPalletID");
}

Maybe it is about that <form></form> doesn't catch the <input type="submit" />

I have one Solution which has different projects like ASP.Net and ASP.Net MVC in this solution. When the user logs in to the application, the same credentials I need to pass to the other project in same solution. It should not ask credentials again, because he has
already logged in. For that I have stored the session details in the sql server database using the SqlServer mode. But the problem is I am unable to get the session which is stored in the database. Any help on this will be appreciated. Thanks in advance.

I am searching for a way to solve this situation:

  • I have a webforms page (.aspx) that has a table on it
  • The rows of the table are generated in the codebehind file (.vb/.cs)
  • each of these dynamic rows has a checkbox, that is added to cell 0 of each row
  • the page has a submit button, that submits the page (postback to same .aspx file)

The idea of the form is like this:

"Please select which of these rows you want to import, by checking those checkboxes"

The problem is that when I press the submit button, the values are lost, probably because the checkboxes (and table rows do not exist when the page loads). Can you suggest how to solve this scenario, so that my checkboxes can be read in the btnImport_Click event after being submitted?

I'm building a task scheduler and i will like to display an alert or a notification at a particular time the task was scheduled for. I read something about cron jobs in php but i'm totally lost. How can this be achieved in ASP.NET MVC using C#.

Basically the user creates a task and sets a time for the task. When the time is reached, a notification is displayed in the browser assuming the user still has the browser opened otherwise, when next the user logs on, the notification still displays.

I have an issue in my hosted website that is some times shows custom error page during the time i will replace the web.config in ftp after that issue is fixed.Whats is reason getting the errors. Thanks in advice.

In my Web.config I got forms type authentication. From VS 2013 I got no problem login to my website. this site is created as standalone application pool using Integrated pipeline mode. when I published this site I cannot login anymore. I got error " Unknown exception occurs while logon to system. In IIS under authentication I have Anonymous Athentication disabled, Forms Athentication enabled, windows athentication enabled and ASP.NET disabled. if I disabled windows athentication I will get not authorize. and even if enable Anonymous athentication I still can't login. check my web.config code below. any idea ? thanks

<?xml version="1.0" encoding="UTF-8"?><configuration>   
<configSections>    
<sectionGroup name="system.web.extensions"   
type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting"type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
</sectionGroup>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
<section name="typeAliases" type="Spring.Context.Support.TypeAliasesSectionHandler, Spring.Core"/>
</sectionGroup>
<sectionGroup name="common">
        <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging"/>
    </sectionGroup>
    <section name="dataContext" type="DotWebDev.Common.Data.DataContextConfiguration, DotWebDev.Common"/>
    <section name="framePage" type="DotWebDev.UI.DynamicPages.Configurations.FramePageConfigurationSection, DotWebDev.UI"/></configSections>
<appSettings>
<add key="autoFormsAuthentication" value="false" />
<add key="enableSimpleMembership" value="false"/>
<add key="PreserveLoginUrl" value="true" />
</appSettings>
<dataContext enabledMSDTC="false" commandTimeout="30">
<settings>
<setting name="MembershipDataContext"connectionType="System.Data.SqlClient.SqlConnection" connectionStringName="Global"/>
<setting name="ExtensionModelDataContext" connectionType="System.Data.SqlClient.SqlConnection" connectionStringName="Global"/>
<setting name="ProductManagementDataContext" connectionType="System.Data.SqlClient.SqlConnection" connectionStringName="Global"/>
</settings>
</dataContext> 
<connectionStrings>
<add name="Global" providerName="System.Data.SqlClient" connectionString="Data Source=.\sqlexpress;Initial Catalog=UadminMgr;Integrated Security=SSPI;persist security info=False; Trusted_Connection=Yes; Max Pool Size=4096; Min Pool Size=10"/>
</connectionStrings>
<system.web>
<compilation debug="true">
        <assemblies>
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
    </compilation>
    <authentication mode="Forms">
        <forms name=".Global" defaultUrl="FramePage.svc" loginUrl="LogOn.aspx" slidingExpiration="true" timeout="60"/>
    </authentication>
    <httpRuntime maxRequestLength="4096"/>
    <pages configSource="Config\pages.config"/>
    <globalization culture="auto" uiCulture="auto"/>
    <httpHandlers>
        <remove verb="*" path="*.asmx"/>
        <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add path="*.aspx" verb="*" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
        <add path="DynamicPage.svc" verb="*" type="DotWebDev.UI.Services.DynamicPageHandler, DotWebDev.UI"/>
        <add path="DynamicPageDataService.svc" verb="GET, POST" type="DotWebDev.UI.Services.DynamicPageDataServiceHandler, DotWebDev.UI"/>
        <add path="DynamicPageDownloadExcel.svc" verb="*" type="DotWebDev.UI.Services.DynamicPageDataToExcelHandler, DotWebDev.UI"/>
        <add path="DynamicPageHtmlPrinter.svc" verb="*" type="DotWebDev.UI.Services.DynamicPageDataToHtmlHandler, DotWebDev.UI"/>
        <add path="DetailPanel.svc" verb="*" type="DotWebDev.UI.Services.DetailPanelPageHandler, DotWebDev.UI"/>
        <add path="AggregatePanel.svc" verb="*" type="DotWebDev.UI.Services.AggregatePanelPageHandler, DotWebDev.UI"/>
        <add path="FramePage.svc" verb="*" type="DotWebDev.UI.Services.FramePageHandler, DotWebDev.UI"/>
        <add path="ContextMonitor.ashx" verb="*" type="Spring.Web.Support.ContextMonitor, Spring.Web"/>
        <add path="*_AppService.axd" verb="*" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add path="ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
    </httpHandlers>
    <httpModules>
        <add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
        <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="PlatformModule" type="DotWebDev.Platform.PlatformModule, DotWebDev.Platform"/>
    </httpModules>
    <machineKey configSource="Config\machineKey.config"/>
    <membership configSource="Config\membership.config"/>
    <roleManager configSource="Config\roleManager.config"/>
    <sessionState mode="InProc" stateNetworkTimeout="30" timeout="14400"/>
    <customErrors configSource="Config\customErrors.config"/>
</system.web>
<system.codedom>
    <compilers>
        <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <providerOption name="CompilerVersion" value="v3.5"/>
            <providerOption name="WarnAsError" value="false"/>
        </compiler>
        <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <providerOption name="CompilerVersion" value="v3.5"/>
            <providerOption name="OptionInfer" value="true"/>
            <providerOption name="WarnAsError" value="false"/>
        </compiler>
    </compilers>
</system.codedom>
<system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>

    <modules>
        <remove name="ScriptModule"/>
        <add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
        <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="PlatformModule" type="DotWebDev.Platform.PlatformModule, DotWebDev.Platform"/>
    </modules>
    <handlers>
        <remove name="WebServiceHandlerFactory-Integrated"/>
        <remove name="ScriptHandlerFactory"/>
        <remove name="ScriptHandlerFactoryAppServices"/>
        <remove name="ScriptResource"/>
        <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        <add name="DynamicPage" path="DynamicPage.svc" preCondition="managedHandler" verb="*" type="DotWebDev.UI.Services.DynamicPageHandler, DotWebDev.UI"/>

        <add name="DynamicPageDataService" path="DynamicPageDataService.svc" preCondition="managedHandler" verb="GET, POST" type="DotWebDev.UI.Services.DynamicPageDataServiceHandler, DotWebDev.UI"/>
        <add name="DynamicPageDownloadExcel" path="DynamicPageDownloadExcel.svc" preCondition="managedHandler" verb="GET, POST" type="DotWebDev.UI.Services.DynamicPageDataToExcelHandler, DotWebDev.UI"/>
        <add name="DynamicPageHtmlPrinter" path="DynamicPageHtmlPrinter.svc" preCondition="managedHandler" verb="*" type="DotWebDev.UI.Services.DynamicPageDataToHtmlHandler, DotWebDev.UI"/>
        <add name="DetailPanel" path="DetailPanel.svc" preCondition="managedHandler" verb="*" type="DotWebDev.UI.Services.DetailPanelPageHandler, DotWebDev.UI"/>
        <add name="AggregatePanel" path="AggregatePanel.svc" preCondition="managedHandler" verb="*" type="DotWebDev.UI.Services.AggregatePanelPageHandler, DotWebDev.UI"/>
        <add name="FramePage" path="FramePage.svc" preCondition="managedHandler" verb="*" type="DotWebDev.UI.Services.FramePageHandler, DotWebDev.UI"/>
    </handlers>
    <defaultDocument>
        <files>
            <clear/>
            <add value="LogOn.aspx"/>
        </files>
    </defaultDocument>
</system.webServer>
<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <behaviors>
        <serviceBehaviors>
            <behavior name="AuthenticationBehavior">
                <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
                <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
        </serviceBehaviors>
        <endpointBehaviors>
            <behavior name="RestfulEndpointBehavior">
                <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
                <webHttp/>
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <bindings>
        <webHttpBinding>
            <binding name="HttpStreaming">
                <security mode="None">
                    <transport clientCredentialType="None"/>
                </security>
            </binding>
        </webHttpBinding>
        <mexHttpBinding>
            <binding name="HttpStreaming" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"/>
        </mexHttpBinding>
    </bindings>
    <services>
        <service name="DotWebDev.Platform.Services.OrganizationService" behaviorConfiguration="AuthenticationBehavior">
            <clear/>
            <endpoint address="http://localhost:51702/Services/OrganizationService.svc" behaviorConfiguration="RestfulEndpointBehavior" binding="webHttpBinding" bindingConfiguration="HttpStreaming" contract="DotWebDev.Platform.Services.IOrganizationService" listenUriMode="Explicit"/>
            <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="HttpStreaming" contract="IMetadataExchange"/>
        </service>
        <service name="DotWebDev.Platform.Services.RoleService" behaviorConfiguration="AuthenticationBehavior">
            <clear/>
            <endpoint address="http://localhost:51702/Services/RoleService.svc" behaviorConfiguration="RestfulEndpointBehavior" binding="webHttpBinding" bindingConfiguration="HttpStreaming" contract="DotWebDev.Platform.Services.IRoleService" listenUriMode="Explicit"/>
            <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="HttpStreaming" contract="IMetadataExchange"/>
        </service>
        <service name="DotWebDev.Platform.Services.HierarchyService" behaviorConfiguration="AuthenticationBehavior">
            <clear/>
            <endpoint address="http://localhost:51702/Services/HierarchyService.svc" behaviorConfiguration="RestfulEndpointBehavior" binding="webHttpBinding" bindingConfiguration="HttpStreaming" contract="DotWebDev.Platform.Services.IHierarchyService" listenUriMode="Explicit"/>
            <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="HttpStreaming" contract="IMetadataExchange"/>
        </service>
        <service name="DotWebDev.Platform.Services.ConcreteDataService" behaviorConfiguration="AuthenticationBehavior">
            <clear/>
            <endpoint address="http://localhost:51702/Services/ConcreteDataService.svc" behaviorConfiguration="RestfulEndpointBehavior" binding="webHttpBinding" bindingConfiguration="HttpStreaming" contract="DotWebDev.Platform.Services.IConcreteDataService" listenUriMode="Explicit"/>
            <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="HttpStreaming" contract="IMetadataExchange"/>
        </service>
    </services>
</system.serviceModel>
<spring>
    <typeAliases>
        <alias name="WebResource" type="DotWebDev.UI.WebResources.WebResource, DotWebDev.UI"/>
        <alias name="WebResourceGroup" type="DotWebDev.UI.WebResources.WebResourceGroup, DotWebDev.UI"/>
    </typeAliases>
    <context>
        <resource uri="~/Spring/all.config"/>
    </context>
</spring>
<common>
    <logging>
        <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
            <!-- Possible values are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF -->
            <arg key="Level" value="ERROR"/>
            <arg key="configType" value="FILE"/>
            <arg key="configFile" value="~/Config/log4net.config"/>
        </factoryAdapter>
    </logging>
</common>
<framePage NavigationBarTitle="$Resources.Common.NavigationBarTitle, DotWebDev.Web$" FramePageTitle="$Resources.Common.FramePageTitle, DotWebDev.Web$" HeaderTemplate="~/Templates/Header.ascx" DefaultPageUrl="Default.aspx" DefaultTabTitle="$Resources.Common.DefaultTabTitle, DotWebDev.Web$" EnableMultipleTabs="true" MaximumTabs="10"/>

I want to save files into database and i can delete it so for that i created a table named Files like below

 public class File 
{
    public int FileID { get; set; }
    public string Name { get; set; }
    public string Path { get; set; }
    public string Extension { get; set; }

}

Does anybody have an idea how to do it. Thanks

I created two resource files, "SOSResources.en.resx" and "SOSResources.pt.resx".

In my aspx page, when I try to use a string from these files as below, I get it from the standard English language resx file.

asp:Literal ID="btnDelete_Text" Text="<%$Resources:SOSResources, String1%>"

However, if I try to get the same string on code-behind as below, I get it from the Portuguese language file (which is the user language).

btnEdit_Text.Text = Resources.SOSResources.String1

The following code is used to handle this process. It is supposed to select the User's language, or English in case this info is not available. However, only the example from code-behind gets the user language. The example from aspx page always gets the strings from the English resx file.

protected override void InitializeCulture()
    {
        string lang;

        if (ActiveUser != null && ActiveUser.Language != null)
        {
            lang = ActiveUser.Language;
        }
        else
        {
            lang = "en";
        }

        Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
        base.InitializeCulture();
    }

Can someone help me? How can I assure that in both cases the page will get the strings from the appropriate language? I'm not sure either if this is the correct way to perform globalization on .NET.

I'm doing a component to format a list, it is an Extension, I wrote the following code, but, when in execution time, it gives me the error:

Cannot convert lambda expression to type 'System.Web.WebPages.HelperResult' because it is not a delegate type

This is the extension:

public static MvcHtmlString FormatMyList<TModel, TValue>(this HtmlHelper<TModel> htmlHelper, IEnumerable<TValue> list,
            Expression<Func<TValue, System.Web.WebPages.HelperResult>> formatExp = null)
        {

            foreach (var item in list)
            {
                var itemFormated = formatExp.Compile().Invoke(item).ToString();
            }

            return new MvcHtmlString("");
        }

View calling:

var test = Html.FormatMyList<ModelType, ListType>(list, formatExp:
        x =>
            @<text>
                This is format of @x.Cambio to test @x.Fala
            </text>);

I already tried to change from HelperResult to dynamic, but didn't work too.

I don't want to use only Func<object, HelperResult> as suggested in some posts in StackOverFlow, because, there will be items inside the <text></text>, that needs to be strongly typed as an item of ListType.

The format can be different in my views, so I can't use a template to ListType.

Is there a way to do that, even that not using the expression?

Thanks

I know that @Html.DisplayFor is used when we need to generate the appropriate html control that would correspond to the property in model. But what is @Html.DisplayName and @Html.DisplayNameFor used for?

Is there a way to render HTML tags from a ViewBag? I am pulling article content out of a database, but the HTML tags included in the article aren't rendered.

For example:

ViewBag.ArticleContent = "Machine <strong>Language</strong> Content";

The tag doesn't render, it just shows up as text. This is a static string, but I get the same issue when I assign to ViewBag.ArticleContent from the database.

I manage to get my media URL using the following syntax:

Umbraco.Media(CurrentPage.MyImage).Url

But, when I try the same using the GetProperty syntax (strangely, I used getProperty for a while from examples online, but that syntax always returned some empty dynamic object), which works fine for other properties, I get all kinds of casting errors:

// results in:
// System.InvalidOperationException: The value of parameter 'id' must 
// be either a string or an integer

Umbraco.Media(CurrentPage.GetProperty("myImage")).Url

// or
Umbraco.Media(CurrentPage.GetProperty("_myImage")).Url

And using some form of Umbraco.TypedContent<Media> led to only more NRE and casting errors. I ultimately tried the following, but that returned an empty list always:

Umbraco.Media("myImage","umbracoFile")

I don't mind using the dynamic syntax, or any other syntax for that matter, but I am surprised that GetProperty apparently returns something different than the dynamic syntax.

Ultimately, all I wanted is to use the _propName syntax (underscore-prefixed name) to get the property of this, or any parent page, whichever is set. Short of querying the AncestorOrSelf list of pages, is there some way to get this to work using "simple" syntax?

Quick update If I do @CurrentPage.GetProperty("_defaultBackgroundImage") I see the media id in the HTML, but when I try to feed it to Umbraco.Media I get InvalidOperationException the value of parameter 'id' must be either a string or an integer. Casting to int give invalid cast and using ToString returns the type name. There must be some way to get back the same integer value I see as when I output it using Razor @-syntax, right?

I am working on a really bit application at the moment. We have around 100 links to subsites at the moment and still growing. Of course they have different level of menu-points (3 level).

At the moment we are not using anything special here, so every link is a ActionLink in my view, most views (>95%) are loaded as partialview in a content div to display it. So you can imagine how the MainMenu.chtml looks like: around 100 actionlinks written down in order, not more not less. It get's even worse: Half of the subsites have a title-div which handels everything by itself: Title, relation to other menu-links (so you can move from Level 3 to Level 2 in the linktree), titlemenu-buttons like close or favorite...
The negative aspects should be clear: a lot of spagethi code, a lot of not well organized links and a lot of code duplicates. If someone whants to add a feature (e.g. a date) in all title bars, he has to do it 50 to 100 times!

So what I thought of is to get this in a XML structure, every Link is a node, you can nicly have relationships, have a lot of attributes to work with, e.g. which link will have a titlebar and you just need to write a generic method to load a title bar.

My problem here at the moment: Is this really best practice? Isn't there a good solution for doing such huge subsites and link amounts?

When I started to work on this XML structure and the rendering of the mainmenu it get's a bit messy: Where to render this XML? I want to have ActionLinks, so I have to do it in my view to have Razor support. But do this in a view feels terrible wrong, it should be in the controller for my main menu - but there I didn't have Razor ActionLink, I would need to write everything myself... which feels terrible too!

Any ideas?

I am developing shopping cart application in MVC 4 where I need to update the amount on changing the cart quantity.

@foreach (var item in Model)
{
    <tr>
        <td>@item.ProductId</td>
        <td>@item.Product.ProductName</td>
        <td id="PriceBx">@item.Product.UnitPrice</td>

        <td id="QtyBx" oninput="calculate()">@Html.TextBox("QuantityBox", item.Quantity, new { style = "width:50px" })</td>
        <td id="result">@String.Format("{0:c}", Convert.ToDouble(item.Quantity) * Convert.ToDouble(item.Product.UnitPrice))</td>

    </tr>
}

In this I need to update the total when the value in QuantityBox is changed.

I tried using Javascript

<script type="text/javascript">
function calculate()
{

    var myBox1 = document.getElementById('QtyBx').value;
    var myBox2 = document.getElementById('PriceBx').value;
    var result = document.getElementById('result');
    var myResult = myBox1 * myBox2;
    result.innerHTML = myResult;
}

I am new to MVC. This is what i have already tried but its not going to new URL on click instead i have to right cick and select Open,then its opening and fetching correctly.

I need that it should be go on particular URL by clicking on it.

@Html.ActionLink("ServersStopped" + "(" + @Model.ServersStopped + ")", "FetchAllServersDown", "Home")

The actual html generated is

<a href="/Home/FetchAllServersDown">ServersStopped(1)</a>

I am developing MVC 4 application in which I need to pass the updated value from the view to controller.

          @foreach (var item in Model)
          {
           <tr>
              <td>@item.ProductId</td>
              <td>@item.Product.ProductName</td>
              <td>@item.Product.UnitPrice</td>
              <td>
                @Html.TextBox("QuantityBox", item.Quantity)
              </td>

             </tr>
            }


           //Update Button

            @using (Html.BeginForm("UpdateCart", "Cart", FormMethod.Post))
            {
                @Html.AntiForgeryToken()
                <input type="submit" id="submit" name="Update" value="Update" />
            }

The values could be entered different for different rows. I need to pass these values from quantity textbox to controller.