Showing posts with label url. Show all posts
Showing posts with label url. Show all posts

August 04, 2014

JQuery tutorial, Get set values,window,height,width frequently used tags, JQuery basics for professionals Part 2

We have seen basics of Jquery with sample code with short and easy examples in our Part 1 (JS Basics, Selectors and scroll bar). Now this is part 2, in this blog we will see how to select elements of different types and set and get values of them using JQuery. 



 // get value from text box  
  alert("Text : "+$("#myText").val());   
   
  // dropdown get selected value  
  alert("Selected : "+$("#MySelect :selected").val());  
         
  // get value from Textarea  
  alert("Text : "+$("#myTextArea").val());   
   
  // get value of check box  
  alert("Checked : "+$("[name='sex']:checked").val());   
   



and Sample Html is:
 <input name="foop" id="myText" type="text" value="Praveen" />   
   <select name="foo" id="MySelect" >  
     <option value="one">one</option>  
     <option value="two">two</option>  
     <option value="three">three</option>  
   </select>   
 <textarea name="foop" id="myTextArea" rows="2" cols="20" >Good blog for learning </textarea>  
   
 <input type="radio" name="sex" value="male" checked='true'>Male   
 <input type="radio" name="sex" value="female" >Female  


How to Set values in html controls or elements using Jquery,

 $('input[name="sex"][value="male"]').attr("checked", true); // checked value of radio box  
   
 $("#MySelect").val("three"); // dropdown value set  
   
 $("#myText").val("Praveen");// text box  
   




var windowWidth = $(window).width(); //retrieve current window width

var windowHeight = $(window).height(); //retrieve current window height

var documentWidth = $(document).width(); //retrieve current document width

var documentHeight = $(document).height(); //retrieve current document height

var vScrollPosition = $(document).scrollTop(); //retrieve the document scroll Top position

var hScrollPosition = $(document).scrollLeft(); //retrieve the document scroll Left position

Blog Part 1 (Basics, Selectors and scroll bar)
Blog Part 2 (Get and set values of different elements)
Blog Part 3 (JavaScript windows code and Cookies) 

 
--
Regards,
Praveen Pandit

January 09, 2014

Best way to get Query string from url in SharePoint / Asp .Net / webApps



The easiest and well know way is to Request.QueryString[“name”]; but many times to get null exception we should check query string and return in appropriate format. Below I have created a private int variable and protected property of it. You can have a look on below code.


protected int ItemID
        {
            get
            {
                if (Request.QueryString["itemId"] != null && Request.QueryString["itemId"].Length > 0)
                {
                    return Convert.ToInt32(Request.QueryString["itemId"]);
                }
                else return 0;
            }
        }



You can Share your findings or issue or Discussion below.

--
Regards,
Praveen Pandit


June 28, 2013

best way to get string, how to get value from Url C#

How to get Query string value, how to get values from url query with validation and best practice.

public int ItemID
{
get
{
if (Request.QueryString["ID"] != null && Request.QueryString["ID"].Length > 0)
{
return Convert.ToInt32(Request.QueryString["ID"]);
}
else return 0;
}
}



Thanks,
Praveen Pandit
MCTS; MCPD
Keep Sharing Knowledge!!