.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Post New Web Links

MVC 3 Beta. Google Analytics Html Helper.

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :ASP.Net
 

Hello,

I think (I read it somewhere and can't find the source again) there is a new Google Analytics Html Helper on MVC 3 Beta.

Where can I find the source for this helper?

Thank You,

Miguel




View Complete Post


More Related Resource Links

Using Dynamic Property inside Html Helper with Razor fires an error

  

Hello,

I have the following with Razor:

@Html.GoogleAjax(View.GoogleAjaxKey, new String[,] { { "jquery", "1.4.2" } })

And the I get a strange error:

  'System.Web.Mvc.HtmlHelper<object>' has no applicable method named 'GoogleAjax' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.

What is strange is that it works fine using:

@Html.GoogleAjax("123", new String[,] { { "jquery", "1.4.2" } })

I tried the following code line:


@View.GoogleAjaxKey

And the key is displayed just fine so the problem is how I use the value of @View.GoogleAjaxKey into Html.GoogleAjax.


Do I need to change something on my Html Helper? Here it is:


    public static MvcHtmlString GoogleAjax(this HtmlHelper helper, String key, String[,] libraries) {

      

Implementing Google Analytics in Asp.net mvc

  
I want to integrate Google analytics in my asp.net mvc application. So im doing some R&D for it to find out which one is the better. I find out a Google Analytic Dashboard Controls which are available at http://gadashboardcontrols.codeplex.com/ But they are server control and im not sure how to implement in asp.net mvc. Secondly can i implement asp.net charts in my asp.net mvc application?

maintainscrollpositiononpostback is not working in Google Chrome 5.0.353.70 beta

  
All --I think that sometimes maintainscrollpositiononpostback is not working in Google Chrome 5.0.353.70 beta.Has anyone else experienced this?Does anyone have a fix for this?Does anyone have an alternative for this?Please advise.Thank you.-- Mark Kamoski

CheckBoxList Html Helper

  

Hello,

I have created a CheckBoxList and a CheckBoxListFor helpers that I am using as follows:

@Html.CheckBoxListFor(u => u.Roles, (MultiSelectList)View.Roles)

The checkboxes are being displayed but they are not being checked with the values from u.Roles. They are all unchecked.

My Html Helpers are as follows:

    public static MvcHtmlString CheckBoxListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, IDictionary<String, Object> htmlAttributes) where TModel : class {

      ModelMetadata metadata = ModelMetadata.FromLambdaBLOCKED EXPRESSION;

      String field = ExpressionHelper.GetExpressionText(expression);

      String name = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(field);

      return CheckBoxList(htmlHelper, metadata.DisplayName ?? metadata.PropertyName ?? field, selectList, htmlAttributes == null ? new RouteValueDictionary() : new RouteValueDictionary(htmlAttributes));

    } // CheckBoxListFor

    public static MvcHtmlString CheckBoxList(this HtmlHelper htmlHelper, String name, IEnumerable<SelectListItem> selectList, 

Google Analytics with asp.net c#

  

Hello ,


        I want to track google analytic ecommerce  data through asp.net c# code. 

        The format I  want  is  :  transaction Id              |      Landing Page Path   |  Date


        If some one did it before or haev any resource to do it , please share with us.

     

Thanks

Udal


Html Helper Customization

  

I am new to this, and looking for best practices in this area.

What is a good way to customize extensions to standardize accross the whole website?

For example I have TextArea which I want to resize to look and feel the same across the website wherever I call it. And similarly I would like to use some sort of a date picker element.

Btw: In addition, I am unable to understand what the row and column arguments do in the Html.TextArea( ... int row, int col, ... ). They did not resize the textarea at all: Html.TextArea( ..., new { width='20', height='10' }  ). I also tried sending in the Height and width arguments in html attributes, but that doesn't seem to work either. Looking for advice in that as well.



Thanks


Custom Strong type HTML Helper for checkboxes?

  

Hi!

MVC contains a strong typed HTML Helper (HTML.CehckBoxFor()) this takes a bool and returns a bool. To make the URL smaller I am thinking to change the bool values on the model object to byte or somthing like that so the url only contains &Parameter=1.

I have found this snippet :

public static string DatePickerFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper,Expression<Func<TModel, TProperty>> expression)
  where TModel : class
{
    var inputName = ExpressionHelper.GetExpressionText(expression);
    return htmlHelper.DatePicker(inputName);
}


But I have no clue how to turn this in to a strong typed HTML Helper for checkbox that takes byte instead of bool. Its also important that the model object is set with byte instead of bool.

Any sugestions?

BestRegards


WebMatrix beta 2 @Analytics.GetGoogleHtml

  

Yesterday I upgraded from WebMatrix beta 1 to beta 2.

Published my site and it worked.

Except locally on my PC I couldn't get @Analytics to work (on beta 2) I got an error that @Analytics was not defined, while it worked on beta 1.

Can anybody tell me what to do?


WebMatrix beta 2 - FileUpload helper doesn't work

  


Hi,

I have this code working in beta 1:

<div>
            <form id="imageForm" method="post" enctype="multipart/form-data" action="#imagesTab">
                <input type="hidden" id="itemId" name="itemId" />
                @FileUpload.GetHtml(
                    initialNumberOfFiles: 1,
                    allowMoreFilesToBeAdded: true,
                    addText: "Add another file",
                    includeFormTag: false)
                <button type="submit" id="submitImageData">Upload</button>
            </form>
        </div>


But now I get Compilation Error:

Compiler Error Message: CS0103: The name 'FileUpload' does not exist in the current context


Any HTML Helper Repositories?

  

Are there any websites with collections of HTML Helpers?  One thing that is holding me back with MVC is reinventing the wheel compared to WebForms.  Unfortunately, I don't have the time or skill to create complicated HTML Helpers such as editible data grid tables with sorting, calendars, sitemaps, logins, etc.

Michael


Awesome HTML minifying function but causes problem at Google Adsense ads - Very Important !

  

function works perfectly. everything works without any problem and source code becomes single line. but problem is about adsense ads. it is getting messed at screen.

 

ads are displayed but their locations are not correct. can anybody help me i appricate that alot

 

thank you

 

    protected override void Render(HtmlTextWriter writer)
    {
        if (this.Request.Headers["X-MicrosoftAjax"] != "Delta=true")
        {
            System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"<script[^>]*>[\w|\t|\r|\W]*?</script>");
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            System.IO.StringWriter sw = new System.IO.StringWriter(sb);
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            base.Render(hw);
            string html = sb.ToString();
            System.Text.RegularExpressions.MatchCollection mymatch = reg.Matches(html);
            html = reg.Replace(html, string.Empty);
            reg = new System.Text.RegularExpressions.Regex(@"(?<=[^])\t{2,}|(?<=[>])\s{2,}(?=[<])|(?<=[>])\s{2,11}(?=[<])|(?=[\n])\s{2,}|(?=[\r])\s{2,}");
            html = reg.Replace(html, string.Empty);
            reg = new System.Text.RegularExpressions

MVC3 Beta @Html.AntiForgeryToken() problem

  

Hi,

I am getting strange error when trying to use @Html.AntiForgeryToken() in my views.


The error is:

[ArgumentNullException: Buffer cannot be null.
Parameter name: buffer]
   System.IO.MemoryStream..ctor(Byte[] buffer, Boolean writable) +9638183
   System.IO.MemoryStream..ctor(Byte[] buffer) +6
   System.Web.Mvc.AntiForgeryDataSerializer.Deserialize(String serializedToken) +97

[HttpAntiForgeryException (0x80004005): A required anti-forgery token was not supplied or was invalid.]
   System.Web.Mvc.AntiForgeryDataSerializer.Deserialize(String serializedToken) +397
   System.Web.Mvc.HtmlHelper.GetAntiForgeryTokenAndSetCookie(String salt, String domain, String path) +160
   System.Web.Mvc.HtmlHelper.AntiForgeryToken(String salt, String domain, String path) +16
   System.Web.Mvc.HtmlHelper.AntiForgeryToken() +10

Am I doing something wrong. The request till this exception is raised is GET, not POST. I thought that on GET the token is generated and than is validated on post.

Please advice.<

Awesome HTML minifying function but causes problem at Google Adsense ads - Very Important !

  

function works perfectly. it makes source code single line. but problem is about Google Adsense ads. their locations get messed up. what might be the reason ?

programming language is c# asp.net 4.0

here the function

 

 

  protected override void Render(HtmlTextWriter writer)
  {
    if (this.Request.Headers["X-MicrosoftAjax"] != "Delta=true")
    {
      System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"<script[^>]*>[\w|\t|\r|\W]*?</script>");
      System.Text.StringBuilder sb = new System.Text.StringBuilder();
      System.IO.StringWriter sw = new System.IO.StringWriter(sb);
      HtmlTextWriter hw = new HtmlTextWriter(sw);
      base.Render(hw);
      string html = sb.ToString();
      System.Text.RegularExpressions.MatchCollection mym

create a html helper for tny mce htlm editor?

  

how can I create a html helper for tny mce htlm editor?


2 simple ways to create Custom Html Helper in ASP.NET MVC

  
ASP.NET MVC facilitates us to create our Custom Html Helper in following simple ways:

1. Creating Extension Method on Html Helper Class
2. Creating Static Methods

ASP.NET, HTML, JavaScript Snippet Support (VS 2010 and .NET 4.0 Series)

  
This post covers another useful improvement in VS 2010 - HTML/ASP.NET/JavaScript snippet support. Snippets allow you to be more productive within source view by allowing you to create chunks of code and markup that you can quickly apply and use in your application with a minimum of character typing.

Visual Studio has supported the concept of "snippets" for VB and C# in previous releases - but not for HTML, ASP.NET markup and JavaScript. With VS 2010 we now support snippets for these content types as well.

ASP.NET 4 and Visual Studio 2010 Web Development Beta 2 Overview

  
Many exciting changes for ASP.NET are coming in the .NET Framework version 4. This document gives an overview of many of the new features that are included in the Beta 2 release of the .NET Framework 4 and of Visual Studio 2010.
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend