Theory of a Deadman Concert

Posted by Grubersauce

Laurie got me tix for Theory of a Deadman at the Newport as a wedding gift.  Sonny and I ventured down and caught the end of the Alabama v Florida game at Eddie George's restaurant and then pounded some 32oz $6.50 beers.  Pop Evil opened for them and was ok... I could do without the douchie lead singer prancing around without his shirt on. 

GRUBERSAUCE.COM IS AWESOME


Theory of a Deadman put on a great show and sounded even better.  Moar pictars are here.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Posted on: 12/7/2008 at 3:06 AM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (5) | Post RSSRSS comment feed

Midas Touch @ Scarlet and Grey Cafe

Posted by Grubersauce

I ventured out in the freezing cold last night to catch up with The Midas Touch who was performing at Scarlet and Grey Cafe, opening for Stretch Lefty and some rasta-like band.

Midas Touch (aka Zac Ziebel) is an incredibly talented rapper.  He tried out something new during his set; he had somebody go out in the crowd before the show and collect a bunch of random words from people and then  integrated those words into his rap.  So kinda like Mad Libs for Rappers.  Very impressive considering he didn't know the words ahead of time.

Check out his music here or on his MySpace page.  But not here.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Posted on: 12/5/2008 at 12:53 AM
Tags: , , , , , , ,
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (11) | Post RSSRSS comment feed

Dynamically adding JavaScript with ASP.NET and AJAX UpdatePanel

Posted by Grubersauce

I ran into problem when trying to implement some custom validation for one of our apps.  We give our customers the ability to specify valid numeric ranges for a textbox, including a 'Step' value (if Step was 2, then only even numbers would be acceptable, if Step was 10 then the value would have to be evenly divisible by 10, etc).

Its not possible to use a ASP.NET RangeValidator because there can be multiple ranges (user may specify 1 to 5 and 8 to 13 are valid or some garbage like that) and that Step shenanigans.

So just throw a CustomValidator and validate on the server, right?  Wrong.  There's a mile and half of other Javascript that needs to execute before, after, and inbetween these validations.

In fact, we aren't even letting .NET handle the client-side calling of the validators... we are calling them explicitly from other JavaScript.... so it looks something like this:

validate_options: function() {
   var isValid = true;
   if (typeof (Page_Validators) != "undefined") {
     for (var i = 0; i < Page_Validators.length; i++) {
       // continue button = validate all options
       if (continueClicked) {
         ValidatorValidate(Page_Validators[i]);
         if (Page_Validators[i].isvalid) {
           continue;
         }
         else {
           return false;
         }
       }   
     }  
   }
}

I know right.  Don't ask.  Anyways.... here is how we are creating and attaching validators to the control we want to check. 

private Panel ConstructValidators()
{

  Panel validators = new Panel();
  foreach (ValidatorInfo vi in ScreenOption.Validators)
  {
    if (vi.Type == ValidatorInfo.ValidatorType.Range)
    {
      var rv = new CustomValidator();
      rv.ControlToValidate = base.ControlDataFieldID;
      string valFunctionName = "RNG" + rv.ControlToValidate;
      string scriptBlockId = "sb" + valFunctionName;
      rv.ID = System.Guid.NewGuid().ToString().Replace("-", "");
      rv.ClientValidationFunction = valFunctionName;     
             
      this.Page.RegisterClientScriptBlock("scriptBlockId, CreateRangeValidationJSFunction(rv.ClientValidationFunction);         
        
      Image img = new Image();
      img.ToolTip = vi.ErrorMessage;
      img.ImageUrl = vi.ImageUrl;
      rv.Attributes.Add("ValType", "Range");
      rv.Controls.Add(img);
      validators.Controls.Add(rv);
    }
   }
   return validators;
}

 

And our CreateRangeValidationJSFunction....

private string CreateRangeJavascriptFunction(string functionName)
{
   System.Text.StringBuilder sb = new System.Text.StringBuilder();
   sb.Append("<script language='javascript' id='sb" + functionName + "'>");
   sb.Append("function " + functionName + "(source, clientargs) {");
   sb.Append("clientargs.IsValid = false;");
   sb.Append("var num = Number(clientargs.Value);");
   foreach(string key in ScreenOption.Ranges.Keys)
   {
     sb.Append("if ( num >= " + ScreenOption.Ranges[key].StartValue.ToString("G"));
     sb.Append(" && num <= " + ScreenOption.Ranges[key].EndValue.ToString("G"));
     if (ScreenOption.Ranges[key].StepValue == 0)
     {
       sb.Append(" )");
     }
      else
     {
       sb.Append(" && num % " + ScreenOption.Ranges[key].StepValue.ToString("G") + " == 0)");
     }
     sb.Append("{clientargs.IsValid = true; return;}");
   }
   sb.Append("}");
   sb.Append("</script>");
   return sb.ToString();
 }

The problem I ran into is my JavaScript method was not getting written out to the client and it was bombing out when it tried to call it.  For a good hour or two I tried to figure out where my JavaScript method was.  The Page.IsClientScriptBlockRegistered method returned true everywhere I checked it.  Scott walked in the room just as the knife was beginning to penetrate the skin on my wrist (remember, down the road, not cross the street).  He pointed out that wouldn't work because we have all our controls in AJAX UpdatePanels.

To get this to work with controls inside UpdatePanel, change 

this.Page.RegisterClientScriptBlock(scriptBlockId, CreateRangeValidationJSFunction(rv.ClientValidationFunction);  

to

this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), scriptBlockId, CreateRangeValidationJSFunction(rv.ClientValidationFunction), false);

For more detail about the ClientScriptManager and how it works, follow this link.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Posted on: 12/2/2008 at 9:29 AM
Tags: , , , , ,
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (2) | Post RSSRSS comment feed