Posted by kinjanshah on September 26, 2008
In one of the functionalities I was developing, I needed to integrate my GridView with JavaScript. I mean I was supposed to change the text in few cells of GridView. So, I dig it little bit and found out a way as I have shown below.
Accessing GridView rows/cells from JavaScript:
<script type=”text/javascript” language=”javascript”>
tblTable=document.getElementById(‘<<Client ID of the GridView>>’);
Cell=tblTable.rows[0].cells[0];
Cell.innerHTML=’Hurra!!!!! I have accessed the first row, first cell’;
</script>
Accessing GridView Rows/cells and Cell Control from JavaScript:
Isn’t it a great way to access GridView from JavaScript?
<script type=”text/javascript”>
tblTable=document.getElementById(‘<<Client ID of the GridView>>’);
Cell=tblTable.rows[0].cells[0];
FirstControl = Cell.childNodes[0];
</script>
Hope this will help you out.
Posted in ASP.NET, JavaScript | Tagged: GridView, JavaScript | Leave a Comment »
Posted by kinjanshah on September 25, 2008
Today, I was working on Validator controls and there was a need to make few validator controls enabled or disabled from JavaScript. So, I was walking through it and I found below few things.
- To enable Validator from JavaScript
ValidatorEnable(<<Validator Client ID>>, true);
- To disable Validator from JavaScript
ValidatorEnable(<<Validator Client ID>>, false);
- To Validate all the Validator control from JavaScript
Page_ClientValidate();
This function will return true if there is no validation error otherwise it will return false.
- To Validate a Specific Validator Group from JavaScript
Page_ClientValidate(<<ValidationGroupName>>)
So, this way we can manipulate validator controls and validation group from JavaScript. I hope this will help you out.
Posted in JavaScript | Tagged: AJAX, JavaScript, Validation Control, Validation Group | Leave a Comment »
Posted by kinjanshah on September 24, 2008
As I was reviewing the ASP.Net code of one of my friends, I found following thing.
Dim intValue As Integer = 10
Dim blnFlag As Boolean
If intValue = 10 Then
blnFlag = True
Else
blnFlag = False
End If
So, I suggested him a shorthand provided in ASP.NET i.e. IIF Construct.
Syntax:
IIF(<<Expression>> ,<<True Part>>,<<False Part>>)
Explanation:
Expression: The Expression which needs to be evaluated.
True Part: What action to be taken if Expression is True
False Part: What action to be taken if Expression is False
Example:
Dim intValue As Integer = 10
Dim blnFlag As Boolean = IIf(intValue = 10, True, False)
So, above shorthand is very much handy to use.
Posted in ASP.NET | Leave a Comment »
Posted by kinjanshah on September 24, 2008
In one of my functionality, I needed to strip all HTML tags from a String and then I need to show it to User. So, I have used Regular Expression for that. Following is the example of it.
Procedure:
- Retrieve All HTML Tags using <(.|\n)*?> Pattern
- Replace them with Empty String and return the Result.
Example 1:
Private Function StripHTML(ByVal htmlString As String) As String
‘”<(.|\n)*?>” -> This pattern Matches everything found inside html tags;
‘”(.|\n)” -> Look for any character or a new line
‘”*?” -> 0 or more occurrences, and make a non-greedy search meaning
‘That the match will stop at the first available ‘>’ it sees, and not at the last one
Dim Pattern As String = “<(.|\n)*?>”
Return Regex.Replace(htmlString, Pattern, String.Empty)
End Function
Example 2:
You can just use one line also as following
Regex.Replace(textBox1.Text,@”<(.|\n)*?>”,”");
Posted in ASP.NET | 2 Comments »
Posted by kinjanshah on September 24, 2008
Hello Development Community,
I Kinjan Shah, Software Engineer, MCP, MCAD would like to give Helping Hands to freshers i.e. New Commers in this field and the vetrans as well.
In This blog I’ll share Tips, Tricks, Hacks about JavaScript, ASP.NET, SQL Server, AJAX and much more. This is just to help every one who is passing through and utilizing their time in finding solutions of the error which I have already Solved. So, basically I would like to save your time by Providing solutions.
You can also post your questions or the problems you face. I’ll be glad to help you out guys.
Thanks and Regards,
Kinjan Shah.
Posted in Uncategorized | Tagged: AJAX, ASP.NET, Error Solving, Helping Hands, JavaScript, Problem Solution, SQL Server | Leave a Comment »