Azure Accounts

Notes of my efforts to expand my understanding of Implementing Microsoft Azure Infrastructure Solutions.

To sign up with Azure, you can use either Microsoft Account ( [email protected], [email protected] etc) or Organization Account.

  • Azure Account – Is a mapping between Microsoft/Organization account to access the azure resources. Azure account is created at Azure Account Center. (account.windowsazure.com). You can have multiple Azure Subscriptions under one Azure account. It also determines the Azure Usage and assigns the Account Administrator.

A person who creates the Azure account becomes the Account Administrator and a Default Service Administrator.

  • Azure Subscriptions – Organize how cloud services are accessed. you need to have subscription in order to access the cloud services. Subscription controls how resource usage is reported, billed and paid. Under single Azure Account, you an have single or multiple subscriptions. Each subscription is billed and paid separately. Each subscription has an Unique ID.
  • Administrative Roles – Account Administrator – Every azure account can have only One account administrator. Account administrator can access the Account Center. He / She can create subscriptions, cancel subscriptions and change billing. Only Account Admin can add / remove Service Administrators.

Account Administrator does not have any access to service in that subscription. He / She can not use any resources on Azure.

Azure automatically assigns Account Administrator as default service administrator when a subscription is created.

  • Administrative Roles – Service Administrator – All subscriptions need a Service Administrator. One service administrator per subscription. This authorize access to the Azure Management Portal.
  • Administrative Roles – Co-Administrator – Can have upto 200 co-administrators. Co- Admins can not delete service Administrators. can not see the billing details on subscription. They can not change associations of subscriptions to Azure Directories.

* based on cloud ranger Microsoft azure training.

asp.net input filtering using validation controls

1. only alphabets & max 5 char FILTER

<asp:RegularExpressionValidator ID="regexTextBox1" 
ControlToValidate="txt1" runat="server" 
ValidationExpression="^[a-zA-Z]{0,5}$" Text="only alphabets & max 5 char" />

2. only numeric & max 5 char FILTER

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" 
ControlToValidate="txt2" runat="server" 
ValidationExpression="^[\d]{0,5}$" Text="only numeric & max 5 char" />

3. only alpha-numeric & max 5 char FILTER

<asp:RegularExpressionValidator ID="RegularExpressionValidator2" 
ControlToValidate="txt3" runat="server" 
ValidationExpression="^[0-9a-zA-Z' ']{0,5}$" Text="alpha numeric & 5 char long" />

C#/Javascript – Shareponit 2010 List Update using Web Service

C# – Shareponit 2010 List Update using Web Service

public static void LockDailyEntry(int rowID)
 {
 spws.Lists oSplistWs = new spws.Lists();
 /*Authenticate the current user by passing their default
 credentials to the Web service from the system credential cache.*/
 oSplistWs.Credentials = System.Net.CredentialCache.DefaultCredentials;

 /*Get Name attribute values (GUIDs) for list and view. */
 System.Xml.XmlNode ndListView = oSplistWs.GetListAndView("UnlockDailyEntry", "");
 string strListID = ndListView.ChildNodes[0].Attributes["Name"].Value;
 string strViewID = ndListView.ChildNodes[1].Attributes["Name"].Value;

 /*Create an XmlDocument object and construct a Batch element and its
 attributes. Note that an empty ViewName parameter causes the method to use the default view. */
 System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
 System.Xml.XmlElement batchElement = doc.CreateElement("Batch");
 batchElement.SetAttribute("OnError", "Continue");
 batchElement.SetAttribute("ListVersion", "1");
 batchElement.SetAttribute("ViewName", strViewID);

 /*Specify methods for the batch post using CAML. To update or delete,
 specify the ID of the item, and to update or add, specify
 the value to place in the specified column.*/
 batchElement.InnerXml = "<Method ID='1' Cmd='Update'>" +
 "<Field Name='ID'>" + rowID + "</Field>" +
 "<Field Name='Status'>Lock</Field>" +
 "</Method>";

 /*Update list items. This example uses the list GUID, which is recommended,
 but the list display name will also work.*/
 oSplistWs.UpdateListItems(strListID, batchElement);
 }

Javascript – Shareponit 2010 List Update using Web Service

function SaveListItem() {
 var soapRequest = '<?xml version="1.0" encoding="utf-8"?>' +
 '<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">' +
 ' <soap12:Body>' +
 ' <UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">' +
 ' <listName>UnlockDailyEntry</listName>' +
 ' <updates>' +
 '<Batch OnError="Continue">' +
 ' <Method ID="1" Cmd="Insert">' +
 ' <Field Name="Status">Lock</Field>' +
 ' </Method>' +
 '</Batch>' +
 ' </updates>' +
 ' </UpdateListItems>' +
 ' </soap12:Body>' +
 '</soap12:Envelope>';

 xmlHttp = new XMLHttpRequest();
 xmlHttp.open('post', 'http://spserver:18000/_vti_bin/lists.asmx', true);
 xmlHttp.setRequestHeader('Content-Type', 'application/soap+xml; charset=utf-8');

 xmlHttp.send(soapRequest);
 }

Adding a Javascript onclick event to a Radio Button List Item

Show – Hide IFrame based on ASP.NET Server side radio button list selection

if (!IsPostBack)
{
foreach (ListItem li in A35.Items)
{
li.Attributes.Add("onclick", "javascript:HideFrame('" + li.Value + "')");
}
}
        function HideFrame(object) {
        //alert("Value Clicked :" + object);
            if (object == 'Yes') {
                document.getElementById("MedFrame").style.display = "none";
            }
            else {
                document.getElementById("MedFrame").style.display = "block";
            }
        }

Javascript – Numeric Only Input in ASP.Net Textbox control

<head runat="server">
    <title></title>
    <script language="javascript">
        function checkIt(evt) {
            evt = (evt) ? evt : window.event
            var charCode = (evt.which) ? evt.which : evt.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57)) {
                status = "This field accepts numbers only."
                return false
            }
            status = ""
            return true
        }
 
    </script>
</head>

In body, add asp.net textbox control and set onKeyPress event to this..

<body>
    <form id="form1" runat="server">
    <asp:textbox id="Q46" runat="server" onKeyPress="return checkIt(event)"></asp:textbox>
    <div>
    
    </div>
    </form>
</body>

Reset or clear a form using Javascript

HTML ‘Reset’ button is an easy way to reset all form fields to their default values

<input type="reset" value="Reset Form">
<input type="button" value="Reset Form" onClick="this.form.reset()" />

or you can use clear form code which checks each field and clear the value.

function clearForm(oForm) {
   
  var elements = oForm.elements;
   
  oForm.reset();

  for(i=0; i<elements.length; i++) {
     
 field_type = elements[i].type.toLowerCase();
 
 switch(field_type) {
 
  case "text":
  case "password":
  case "textarea":
         case "hidden": 
   
   elements[i].value = "";
   break;
       
  case "radio":
  case "checkbox":
     if (elements[i].checked) {
       elements[i].checked = false;
   }
   break;

  case "select-one":
  case "select-multi":
              elements[i].selectedIndex = -1;
   break;

  default:
   break;
 }
    }
}

Javascript – Array operations

Creating an Array

var days  = [‘Mon’,’Tue’,’Wed’,’Thur’,’Fri’,’Sat’,’Sun’];
alert(days[0]);

Adding an item at the end of an Array

var properties = [‘red’,’14px’,’Arial’];
properties[3] = ‘bold’;
// or
properties[properties.length]=’bold’;
// or
properties.push(‘bold’);

Adding an item at the beginning of an Array

Properties.unshift(‘bold’);

Deleting an item from an Array

var p=[0,1,2,3]
var removedItem = p.pop();

POP() -removes the last item from the array.
SHIFT() -removes the first item from the array

Adding and Deleting with splice()

var fruit = [‘apple’,’pear’,’kiwi’,’orange’];
fruit.splice(1,2);
// removes pear and kiwi from array

Adding item with splice()

var fruit = [‘apple’,’pear’,’kiwi’,’orange’];
fruit.splice(2,0,’grapes’,’banana’);
//2 is the index where new item will be inserted, and 0 means you do not want to delete any items.