Monday, January 31, 2011
Pass input to Dialog window and return back to the Parent window using JavaScript
Ex: Search and assign a doctor to a patient using doctor appointment screen. Search doctor screen should open as a diglog box and return the selected doctor back to the Appointment screen.
Solution:
Appointment Screen
Doctor Search Screen
Sunday, January 30, 2011
| Plug-in Name | Documentation | Sample | |
|---|---|---|---|
| Overlay | http://flowplayer.org/tools/overlay/index.html Download – http://flowplayer.org/tools/download/index.html | ||
| Tabs | http://flowplayer.org/tools/demos/tabs/index.html | ||
| Scrollable | http://flowplayer.org/tools/demos/scrollable/index.html | ||
| Tooltip | http://flowplayer.org/tools/tooltip/index.html | ||
| tablesorter | http://tablesorter.com/docs/index.html | ||
| Jquery Form Plugin | http://malsup.com/jquery/form/ |
Finding the Current View in ASP.NET MVC
public static string GetCurrentView(this HtmlHelper helper)
{
string controller = helper.ViewContext.RouteData.GetRequiredString("controller");
string view = helper.ViewContext.RouteData.GetRequiredString("action");
return controller + "_" + view;
}
Ex : string currentView = Html.GetCurrentView();
How to get client's IP Address in Load Balanced Environment
public static string GetIPAddress(NameValueCollection serverVariables)
{
var ip = serverVariables["HTTP_X_FORWARDED_FOR"];
if (!string.IsNullOrEmpty(ip))
{
string[] ipRange = ip.Split(',');
if (null != ipRange && ipRange.Length > 0)
{
int le = ipRange.Length - 1;
string trueIP = ipRange[le];
ip = trueIP;
}
else
{
ip = serverVariables["REMOTE_ADDR"];
}
}
else
{
ip = serverVariables["REMOTE_ADDR"];
}
return ip;
}
Ex: string userIPAddress = GetIPAddress(Request.ServerVariables);
Design an Attribute that forces an unsecured HTTP request to be sent over HTTPS in ASP.NET MVC
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class SampleRequireSSL : RequireHttpsAttribute
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
if (Sample.Web.Areas.Admin.Helpers.ConfigSettings.RequireSSL)
{
base.OnAuthorization(filterContext);
}
}
}
How to get render HTML from a View by passing Model as parameter in ASP.NET MVC
protected string RenderViewToString(string viewPath, T model)
{
using (var writer = new StringWriter())
{
var view = new WebFormView(viewPath);
var vdd = new ViewDataDictionary(model);
var viewCxt = new ViewContext(ControllerContext, view, vdd, new TempDataDictionary(), writer);
viewCxt.View.Render(viewCxt, writer);
return writer.ToString();
}
}
Ex : EmployeeViewModel model = GetEmployeeModel(21);
string htmlString = RenderViewToString("~/Views/EmployeeView.ascx", model);
Tuesday, May 11, 2010
How to change SharePoint Workflow status to a custom value
Step 1 - Add following to workflow.xml file
<ExtendedStatusColumnValues>
<StatusColumnValue>Need Restart</StatusColumnValue>
<StatusColumnValue>Waiting for Approval</StatusColumnValue>
</ExtendedStatusColumnValues>
Step 2 - Use SharePoint Workflow SetState shape.
Bind a field workflowState to its State Property.
MethodInvoking - setWorkflowStatus_MethodInvoking
private void setWorkflowStatus_MethodInvoking(object sender, EventArgs e)
{
//// SPWorkflowStatus.Max for "Need Restart"
//// SPWorkflowStatus.Max + 1 for "Waiting for Approval"
this.workflowState = (int)SPWorkflowStatus.Max;
}
Step 3 - For an existing feature, deactivate - uninstall - install - Activate the feature for the above changes to reflect.