Posts

Showing posts from November, 2012

Bind the Events to the Dynamically Created Rows in a HTML Table

I found a solution to bind the events to the dynamically created buttons in a HTML.Some times we need to add a row to the existing HTML table with some inputs.That dynamically created row is not visible in the page source.Try It !

So to attach the events also we need to do like this


var newRow ="<tr> <td></td> <td><input type='text' id='tbNameDyn'/></td> <td> <input type='text' id='tbAgeDyn'/></td> <td><input type='checkbox' id='tbResultDyn'/></td><td><input type='submit' name='submitButton' value='Save Row' id='btnSaveRowDyn' onclick='DynButtonClick();'> </td></tr>";// $('#webgrid > tbody:last'). $('#webgrid tbody:last').append(newRow);Here I have binded the button with the event "onClick" function "DynButtonClick".See the Code too


function D…

Make the Textbox as Label using CSS

This is a simple tip to make the textbox as label in the Web Pages.We need to just add a simple CSS to the input text.See code snippet


.textboxAslabel {border:none;background-color:#FFF;border-color:#FFF;}
Here I have mentioned the background-color and border-color as "white".In my application the background-color is white.So according to your background-color change it.Now Apply that to the textbox.See this Image


Single to handle multiple "Submit" button Clicks in MVC3 Razor View

Last week, I have faced a problem on handling the multiple "Submit"  buttons clicks in a View.I am not very good at MVC3 but I want to share my experience so that others can find some solution regarding this problem.

Suppose we have many Submit buttons in a View where we want to handle the different functions. In the Controller of the We need to write the Code for different submit buttons as given below

[AcceptVerbs(HttpVerbs.Post)]public ActionResult FormActions(string submitButton){switch(submitButton.ToLower()){case"click to know date":this.SetNotification(DateTime.Now.Date.ToString("dd-MMM-yyyy"), NotificationEnumeration.Success,true);return View("index");break;case"click to know time":this.SetNotification(DateTime.Now.ToString ("T"), NotificationEnumeration.Success,true);return View("index");break;default:return View("index");break;}}The View Code is given bel…