Jump to content


  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About kunals

  • Rank
  1. kunals


    hi there,If you can tell me more abt what exactly you need then i guess i can help you.so please mail some details.ThanksKunal
  2. kunals

    how to disable item in listbox

    DO THE FOLLOWING TO ACHIEVE THE SOLUTION:Add a CheckBoxList to your ASP.NET WebForm and give it an ID of checkBoxListTest. Add a call to the LoadCheckBoxList in the Page_Load event. Add the LoadCheckBoxList method to your webpage class. Add the JavaScript function inside the head of the HTML. ASP.NET CodeBehindCODEBEHIND:The following method adds the onclick function disableListItems to the CheckBoxList attributes collection. The function will disable all the items except for the last item in the list when it is checked. The method also adds three items to the CheckBoxList.private void Page_Load(object sender, System.EventArgs e){ if(!this.IsPostBack) { LoadCheckBoxList(); }} private void LoadCheckBoxList(){ this.checkBoxListTest.Attributes.Add("onclick", "disableListItems('checkBoxListTest', '2', '3')"); // Add three items to the CheckBoxList. for(int i=0; i < 3; i++) { ListItem item = new ListItem(i.ToString(), i.ToString()); this.checkBoxListTest.Items.Add(item); }}The following code is the JavaScript function that is invoked by the onclick event of the CheckBoxList.JavaScript Function:/*******************************************************************This is the javascript function that is invoked when the checkboxlistis clicked.Function: disableListItems.Inputs: checkBoxListId - The id of the checkbox list. checkBoxIndex - The index of the checkbox to verify. i.e If the 4th checkbox is clicked and you want the other checkboxes to be disabled the index would be 3. numOfItems - The number of checkboxes in the list.Purpose: Disables all the checkboxes when the checkbox to verify is checked. The checkbox to verify is never disabled.Author: Kunal Shekhar********************************************************************/function disableListItems(checkBoxListId, checkBoxIndex, numOfItems){ // Get the checkboxlist object. objCtrl = document.getElementById(checkBoxListId); // Does the checkboxlist not exist? if(objCtrl == null) { return; } var i = 0; var objItem = null; // Get the checkbox to verify. var objItemChecked = document.getElementById(checkBoxListId + '_' + checkBoxIndex); // Does the individual checkbox exist? if(objItemChecked == null) { return; } // Is the checkbox to verify checked? var isChecked = objItemChecked.checked; // Loop through the checkboxes in the list. for(i = 0; i < numOfItems; i++) { objItem = document.getElementById(checkBoxListId + '_' + i); if(objItem == null) { continue; } // If i does not equal the checkbox that is never to be disabled. if(i != checkBoxIndex) { // Disable/Enable the checkbox. objItem.disabled = isChecked; // Should the checkbox be disabled? if(isChecked) { // Uncheck the checkbox. objItem.checked = false; } } }}Conclusion:The above code shows that it is possible to enable/disable individual items within a ListBox Server Control in ASP.NET. You can modify the C# and JavaScript code to meet your needs
  3. Hi there,please look in the comments below hope this will help you if not then be specific to your problem?To start, let's look at an example -- one where a string is built up by repeating the same character over and over: class MyTimer { private final long start; public MyTimer() { start = System.currentTimeMillis(); } public long getElapsed() { return System.currentTimeMillis() - start; } } public class AppDemo1 { static final int N = 47500; public static void main(String args[]) { // build up string using + MyTimer mt = new MyTimer(); String str1 = ""; for (int i = 1; i <= n; i++) { str1 = str1 + "*"; } system.out.println("elapsed time #1 = " + mt.getelapsed()); // build up string using stringbuffer mt = new mytimer(); stringbuffer sb = new stringbuffer(); for (int i = 1; i <= n; i++) { sb.append("*"); } string str2 = sb.tostring(); system.out.println("elapsed time #2 = " + mt.getelapsed()); // sanity check if (!str1.equals(str2)) { system.out.println("str1/str2 mismatch"); } } } When you run this program, the result should be something like this: elapsed time #1 = 61890 elapsed time #2 = 16Approach #2 explicitly uses StringBuffer, while approach #1 uses it implicitly as part of the implementation of the + operator. You can examine the bytecodes used to implement the first approach by saying: javap -c -classpath . AppDemo1Why such a huge time difference between the two approaches? The second approach appends characters to a StringBuffer, which is quite efficient. Doesn't the first approach do the same? Actually, it doesn't. The statement: str1 = str1 + "*";does not append characters to the string referenced by str1. That's because Java strings are immutable, they don't change after they're created. What actually happens is that: A StringBuffer is set up str1 is copied to it The "*" is appended to the buffer The result is converted to a string The str1 reference is made to point at that string. The old string that str1 previously referenced is then made available for garbage collection. The loop in the demo goes through N iterations, and on each iteration, the contents of str1 (containing N-1 characters) must be copied to the buffer. This behavior implies that the first approach above has quadratic or worse performance. "Quadratic" means that the running time is proportional to the square of N. It is possible to effectively freeze an application by using this kind of loop. The AppDemo1 example illustrates the case where you're repeatedly concatenating one string to another, such that both strings must be copied to a temporary area (StringBuffer), a new string created, and then the original string reference made to point at the new string. But what if you're not doing this kind of operation, and instead, you simply have some code like this: public String toString() { return "X=" + x + " Y=" + y; }There's no loop or repetition here, and no string that keeps getting longer and longer. Is there any harm in using + instead of StringBuffer in this example? To answer that question, let's look at some more code: class MyPoint { private final int x, y; private final String cache; public MyPoint(int x, int y) { this.x = x; this.y = y; cache = "X=" + x + " Y=" + y; } public String toString1() { return "X=" + x + " Y=" + y; } public String toString2() { StringBuffer sb = new StringBuffer(); sb.append("X="); sb.append(x); sb.append(" Y="); sb.append(y); return sb.toString(); } public String toString3() { String s = ""; s = s + "X="; s = s + x; s = s + " Y="; s = s + y; return s; } public String toString4() { return cache; } } class MyTimer { private final long start; public MyTimer() { start = System.currentTimeMillis(); } public long getElapsed() { return System.currentTimeMillis() - start; } } public class AppDemo2 { static final int N = 1000000; public static void main(String args[]) { MyPoint mp = new MyPoint(37, 47); String s1 = null; String s2 = null; String s3 = null; String s4 = null; // toString1 MyTimer mt = new MyTimer(); for (int i = 1; i <= N; i++) { s1 = mp.toString1(); } System.out.println("toString1 " + mt.getElapsed()); // toString2 mt = new MyTimer(); for (int i = 1; i <= N; i++) { s2 = mp.toString2(); } System.out.println("toString2 " + mt.getElapsed()); // toString3 mt = new MyTimer(); for (int i = 1; i <= N; i++) { s3 = mp.toString3(); } System.out.println("toString3 " + mt.getElapsed()); // toString4 mt = new MyTimer(); for (int i = 1; i <= N; i++) { s4 = mp.toString4(); } System.out.println("toString4 " + mt.getElapsed()); // sanity check to make sure equivalent // results returned from each toString method if (!s1.equals(s2) || !s2.equals(s3) || !s3.equals(s4)) { System.out.println("check error"); } } } This demo sets up a class MyPoint, that is used to represent X,Y points. The demo implements a variety of toString methods for the class. The result of running the program should look something like this: toString1 2797 toString2 2703 toString3 5656 toString4 32The first two approaches, using + and StringBuffer, have nearly identical performance. So you might conclude that these two approaches are in fact the same. The bytecodes generated for toString1 indicate that a StringBuffer is set up, and then the various strings are simply appended to it. The resulting code is very similar to toString2. But it's not quite that simple. The first problem is that you can't always formulate the value to be returned from toString as a single expression. toString3 and toString1 produce identical results. But toString3 takes twice as long to run, for the same reasons as described for the AppDemo1 example. The AppDemo2 example illustrates the situation where you need to build up the return value a piece at a time. In such a case, toString2, using an explicit StringBuffer, is a better choice. The other problem concerns a statement found in the Java Language Specification section, which says: An implementation may choose to perform conversion and concatenation in one step to avoid creating and then discarding an intermediate String object. To increase the performance of repeated string concatenation, a Java compiler may use the StringBuffer class or a similar technique to reduce the number of intermediate String objects that are created by evaluation of an expression. This statement suggests that a Java compiler is not required to optimize an expression such as: str1 + str2 + str3 + ...as is currently done for the toString1 method above, but instead can create intermediate string objects. So it pays to be cautious in your use of the + operator, especially for long strings or within loops. Note that there's an even faster way to implement toString for this example. MyPoint is an immutable class, meaning that instances cannot be modified after creation. Given this, the value returned by toString will always be the same. Because the value is always the same, it can be computed once in the MyPoint constructor, and then simply returned by toString4. This kind of caching is often very useful, but not without drawbacks. If the class is mutable, then caching might not make sense. The same is true if computing the cache value is expensive, if the cache ties up a lot of memory, or if the toString method is called infrequently.
  4. kunals


    Hope this Doc will help you in understanding the whole process.Let me know if yo have any other Q.thanks,kunal Shekhar. Configuration_Management.doc
  5. kunals

    Exploratory Testing

    On a recent project where we were implementing a service oriented architecture (for the first time on a large scale) we wanted to leverage the design of the system to test early. The plan was to have testers run local servers, get the latest complete code (after developers were done and everything was unit tested), and run component level tests based on risks identified by the test team. We would use automation and manual testing to flush out edge conditions, mapping errors, and un-captured exceptions.in this scenario what u can feel is the testers also doesn't have to stick to testcases and they can go based on their instinct and product and domain knowledge.So now if i put this is simple wordsexploratory testing is nothing but : 1.Simultaneous learning.2. test design and 3.test execution.IN other words i'm takin it very close to Agile testing.Thanks,Kunal Shekhar.
  6. Well said jaggu,I just want to add one more point to that:The Impact Analysis(what is been done in development phase for fixing a bug) is a base to decide on the test cases selected for Regression testing.So along with testing the same cases with new set of data we also look for the areas which is been in grey for that particular Fix.Thanks,Kunal Shekhar.
  7. kunals

    build, version and release

    Hi there ,PFA document about the configuration management which will help you in understanding the whole process rather than learning it in bits n pieces. Configuration_Management.doc
  8. Well as far as my experience is concerned there is nothing specific to testing when it somes to HR round . still if you have any specifis Q then post that we'll answer it to the best of our knowledge.what really matters in HR round is your attitude and your communication skills. Basically this is what they r concerned about.Thanks,Kunal Shekhar.