Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
3,500,938
3,500,939
How do I improve my style of JavaScript coding?
<p>My style of coding, I would say, is weak from a structural point of view. I can never conform my code to a style suitable for reuse or maintainability. I can't code exactly as you'd take a "professional's" code to be. And now I would like to start learning how to improve my style of coding that can match that of professionals. Do you have any resources that could help me out? Thanks.</p>
javascript
[3]
5,517,951
5,517,952
Randomly NoneType object is not callable error
<p>Recently I've got this problem in my application:</p> <blockquote> <p>File "main.py", line 31, in File "app.pyc", line 205, in run TypeError: 'NoneType' object is not callable"</p> </blockquote> <p>My code:</p> <pre><code>xml = EXML() for pid, product in store.products.items(): xml.addRow() xml.addCell((product['name']).encode('utf-8'), "String") xml.addCell((product['symbol']).encode('utf-8'), "String") xml.addCell((product['brand_name']).encode('utf-8'), "String") # line 205 xml.addCell(str(product['price']), "String") </code></pre> <p>Python 2.7 32-bit</p> <p>It's wired, because this showed up after ~1000 iterations, with out any previus problem. This application scans online store to get current prices. Firstly I thought that somewhere I missed someting, and as result there is <code>None.encode('utf-8')</code>, but no, and "".encode('utf-8') seems to work. Moreover, I can't reproduce this error on testing site, just sometimes shows up while hard-working with ~2500 products. What are possible other sources of this error?</p>
python
[7]
5,226,605
5,226,606
iPhone - UIWebView multiple locks
<p>I receive the following error message in my debugger console:</p> <pre><code>bool _WebTryThreadLock(bool), 0x7400460: Multiple locks on web thread not allowed! Please file a bug. Crashing now... </code></pre> <p>This occurs when I:</p> <ol> <li>Load an UIViewController</li> <li>Load an UIWebView from within this UIViewController</li> <li>Then I push a second UIViewController from the first UIViewController</li> <li>Load a second UIWebView from within the second UIViewController</li> </ol> <p>I believe this has something to do with access to the UIWebView resource, but I´m really not sure.</p> <p>Can anyone help me with this error?</p>
iphone
[8]
5,511,497
5,511,498
"this" refers to something else?
<p>When I run this code:</p> <pre><code>var Test = function() { return this.stuff; }; Test.stuff = 'Neat!'; document.write(Test() || 'Not neat.'); </code></pre> <p>Why do I get 'Not neat.'? Why can't I access the stuff property using <code>this.stuff</code>?</p>
javascript
[3]
1,597,997
1,597,998
How to submit the form after log back in when session expired?
<p>My ASP.NET project now doing this:</p> <ol> <li>Warning users session will be expired in 5 mins. </li> <li>After session expired, when user click "submit", it redirect to the log in page.</li> </ol> <p>How can I "submit" the page after log in, continue execute what it suppose to do?</p> <p>Thanks.</p>
asp.net
[9]
5,320,402
5,320,403
How to ignore jquery variable?
<p>I have code, that looks something like this:</p> <pre><code> (function($) { $(document).ready(function() { function getHash(){ var h = document.location.href.split('#'); return h.length == 1 ? "" : h[1]; } var $newdiv = $('...html code here...'); function checkit() { if(getHash() != "#ignoreDivButton") $('html').html($newdiv); } checkit(); $('#ignoreDivButton').click(function(){ document.location.href = document.location.href.split('#')[0] + "#ignoreDivButton"; location.reload(); }); }); })(jQuery); </code></pre> <p>What I need, is to reload page by clicking on #ignoreDivButton but without loading the newdiv. I just can't get how to ignore the variable. Thank you in advance.</p>
jquery
[5]
5,105,178
5,105,179
How do I display the Java console?
<p>I'm aware of the fact that you can set it to "show" in the Java control panel, but that's not what I'm asking about. I'm curious about the other options... "Do not start" is pretty straightforward, but what about "Hide"? That would seem to imply that it is indeed running. If so, how can I make it show on demand from the hidden state?</p> <p>Reason: It's annoying to have it open ALL the time, hoping there's a way to (preferably via keystroke) bring it from "hidden" to "shown" state for occasional debugging.</p>
java
[1]
3,635,249
3,635,250
How to implement permission validation in a simple way in PHP?
<p>I'm new to PHP. In JavaEE, a interceptor can be used to simplify the permission validation. After you implement and configure the interceptor, the validation will be automatically run before business logic. Is there a simple way to implement this function in PHP?</p>
php
[2]
3,256,229
3,256,230
How search number within range formatted string using delimiter?
<p>If my formatted string is:</p> <pre><code>$range = '0|500|0.50'; </code></pre> <p>How can I search if number (200) exists in range between 0 and 500?</p> <p>Here is what I tried, if there is better idea tell me please</p> <p>Exploding the range first?</p> <pre><code>$arr = explode('|', $range); $min = min($arr); $max = max($arr); </code></pre> <p>But I do not know how to progress from there? I even do not know how to exlcude the 3rd parameter from range 0.50 in this case. Can anyone give me a starting point? I basically want to run search for numbers against range (formatted that way with | delimiter) </p> <p>Thanks!</p>
php
[2]
4,213,811
4,213,812
Is there any overhead with referencing static functions as part of a class definition?
<p>I am currently implementing some utility functions for implementing some libraries I am working on. I was forced to choose between segmenting the functions as static members as part of a class definition within a more general namespace, or enter more specific namespace and then define the functions. I choose the former feeling as it was more flexible in the way those utility classes may be drawn into scope (using or inheritance) though I was unsure whether there was any overhead associated with this design choice or not:</p> <p>Is</p> <pre><code>namespace Utilities { struct CharUtil { static void foo(); } } Utilities::CharUtil::foo(); </code></pre> <p>slower than</p> <pre><code>namespace Utilities { namespace CharUtil { void foo(); } } Utilities::CharUtil::foo(); </code></pre> <p>?</p> <p>Is the former faster using inheritance?</p>
c++
[6]
3,824,421
3,824,422
How to find out the near by restaurants using current location details
<p>Thanks in advance. I want to find out the near by restaurant details using current location details like latitude,longitude details. Is there any api for that, could any one have idea , please let me know.</p> <p>Answer : </p> <p>Hi all , I am using <a href="http://maps.google.com/?q=restaurents+near+hyderabad&amp;output=kml" rel="nofollow">http://maps.google.com/?q=restaurents+near+hyderabad&amp;output=kml</a> this url now if it is not working i can follow the urls given by @Karthikeyan.</p>
iphone
[8]
3,266,261
3,266,262
Use of setting ValidateRequest to false in ASP
<p>What is the use of setting ValidateRequest to False in ASP.Net? </p>
asp.net
[9]
4,965,420
4,965,421
highlight span tag content line by line in JQuery
<p>I used these lines of code for highlighting my sentences,every thins is OK but i want to highlight line by line(this code highlight all lines in span tag together)</p> <p><strong>JavaScript Code</strong></p> <pre><code>$(document).ready(function(){ var seconds = 5; var el = $('span#test'); var width = el.outerWidth(); var height = el.outerHeight(); var wrapper = $('&lt;span&gt;').css({ width: width + 'px', height: height + 'px', position: 'relative' }); var background = $('&lt;span&gt;').css({ width: 0, height: height + 'px', position: 'absolute', background: '#0f0' }); wrapper.append(background); wrapper.append(el.css('position','absolute')); $('body').append(wrapper); background.animate({width: '+=' + width},1000*seconds); });​ </code></pre> <p>How can i do it?</p> <p>I know i can do it by splitting it's to chars(<strong>like this:</strong> <a href="http://jsfiddle.net/9UgEF/34/" rel="nofollow">Highligh Line By Line</a>) but i used custom font.</p> <p><strong>my Demo:</strong><a href="http://jsfiddle.net/9UgEF/41/" rel="nofollow">http://jsfiddle.net/9UgEF/41/</a></p> <p>please help!</p>
jquery
[5]
4,221,555
4,221,556
Create a dynamic select object in Javascript
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/6601028/how-to-populate-the-options-of-a-select-element-in-javascript">How to populate the options of a select element in javascript</a> </p> </blockquote> <p>I would like to create a dynamic select tag and options tag in javascript. Any suggestions? </p>
javascript
[3]
1,027,714
1,027,715
Reinventing the Wheel: the time class
<p>I am trying to reinvent the wheel and I want to create a time class in c++, I do want this class to be dependent of any c/c++ std libraries, why ? because I am writing a small OS for fun, but I can't seem to find to find information regarding how I would start. can anyone lead me in the right direction ? most of the search I find are just how to use a std library to get time... </p> <p>Thanks</p> <p>Sorry let me fix that a small os that is x86 for now.</p>
c++
[6]
1,111,095
1,111,096
home button/long press breaks activity stack
<p>I have A,B activities..</p> <p>A is the launcher activity.</p> <p>User goes from A -> B</p> <p>User presses home button -> Launches browser -> long press on home button -> selects my application -> now B is on stack and hitting back button does not take him from B -> A.</p> <p>A is singleInstance activity.</p> <p>I want A activity to be accessible from anywhere with help of back button.</p> <p>Is there a simple way OR do I have to catch back button event and start A activity.</p> <p>And since A is single instance it will be fetched from instance which is already there on stack/dvm.</p> <p>Please suggest...</p>
android
[4]
4,131,822
4,131,823
Finding ASP.NET source code
<p>Where can I find source code for e.g. XmlSiteMapProvider and other "built-in" stuff for ASP.NET (3.5)?</p>
asp.net
[9]
3,068,744
3,068,745
Javascript While loop integers
<p>I have to create a while loop displaying the integers from 1-20 but only 5 integers per line. I can't get the 5 integers per line part. What is the best way to do that?</p>
javascript
[3]
779,790
779,791
OOP in Python!! My First assignment in Python
<p>I have no clue how OOP works in Python. I tried to get ideas from online tutorials but I couldn't understand clearly and my due date for this assignment is tomorrow morning. :( I would really appreciate if you guys could help me in solving this!</p> <blockquote> <h3>Question 1:</h3> <p>Write a class named Car that has the following data attributes:</p> <ul> <li><code>__year_model</code> (for the car's year model)</li> <li><code>__make</code> (for the make of the car)</li> <li><code>__speed</code> (for the car's current speed)</li> </ul> <p>The Car class should have an <code>__init__</code> method that accept the car's year model and make as arguments. These values should be assigned to the object's <code>__year_model</code> and <code>_make</code> data attributes. It should also assign 0 to the <code>__speed</code> data attributes.</p> <p>The class should also have the following methods:</p> <ul> <li><code>accelerate</code><br> The accelerate method should add 5 to the speed data attribute each time it is called.</li> <li><code>brake</code><br> The brake method should subtract 5 from the speed data attribute each time it is called.</li> <li><code>get_speed</code><br> The get_speed method should return the current speed.</li> </ul> <p>Next, design a program that creates a Car object and then calls the accelerate method five times. After each call to the accelerate method, get the current speed of the car and display it. Then call the brake method five times. After each call to the brake method, get the current speed of the car and display it.</p> </blockquote>
python
[7]
3,360,238
3,360,239
i.MX233 application processor for music player
<p>I would like to implement a music player on a cheap microprocessor/microcontroller that supports DSP and WiFi. I found i.MX233 applications processor from Freescale. Any other option?</p>
android
[4]
942,944
942,945
How do I transfer a value from a text box to a new window using Javascript?
<p>I have created a form so the user can complete his name, last name, credit card number etc.</p> <p>All the information is provided by the user.</p> <p>When the user has ended his work he should press a button and a new window pops up with the user's information revised.</p> <p>Anyone has a suggestion on this? I would be grateful.</p>
javascript
[3]
3,094,532
3,094,533
python 2.7 iterating index error
<pre><code>import re address1 = [] address2 = [] city = [] state = [] zipCode = [] modifiedShipping_address1 = ( ['#### Example Rd. SE', 'City, OH\xa0#####', 'United States', ''], ['### Street Ct', 'Apt B', 'City, SC\xa0#####', 'United States', '']) for i in modifiedShipping_address1: address1.append(i[0]) if len(i) == 4: address2.append('') cityIndex = str(i[1]).find(',') city.append(i[1][:cityIndex]) state_re = re.compile(', (.*?)\\xa0') state_pat = re.findall(state_re, str(i[1]).strip()) for i in state_pat: state.append(i) zip_re = re.compile('\\xa0(.*?)') zip_pat = re.findall(zip_re, str(i[1]).strip()) for i in zip_pat: zipCode.append(i) else: address2.append(i[1]) cityIndex = str(i[2]).find(',') city.append(i[2][:cityIndex]) state_re = re.compile(', (.*?)\\xa0') state_pat = re.findall(state_re, str(i[2]).strip()) for i in state_pat: state.append(i) zip_re = re.compile('\\xa0(.*?)') # This line throws the exception: zip_pat = re.findall(zip_re, str(i[2]).strip()) for i in zip_pat: zipCode.append(i) state = state[:] zipCode = zipCode[:] print state print zipCode </code></pre> <p>When run, the code produces this output:</p> <pre><code>['OH'] [] Traceback (most recent call last): File "iterating.py", line 37, in &lt;module&gt; zip_pat = re.findall(zip_re, str(i[2]).strip()) IndexError: string index out of range </code></pre> <p>How do I go about fixin this? Thank you. I do not understand where indexError is coming from.</p>
python
[7]
3,163,231
3,163,232
How to get referral site URL?
<p>I have posted my site URL on Facebook. Now I am coming to my site after clicking the link shared on Facebook. I want to capture the Facebook URL from where I am coming to my site. I want to get the referral site URL in my webapplication.</p> <p>How do I get the referral site URL using C#?</p>
c#
[0]
3,393,063
3,393,064
What does the ? in Android XML mean
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2733907/question-mark-in-xml-attributes-for-android">Question mark (?) in XML attributes for Android</a> </p> </blockquote> <pre><code>&lt;TextView android:id="@+android:id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppearance="?android:attr/textAppearanceLarge" android:ellipsize="marquee" android:fadingEdge="horizontal" /&gt; </code></pre> <p>what does "?android:attr/textAppearanceLarge" do? Does it have a name? Why doesn't it use an "@" instead? Can I use this syntax in my own code? Where can I read more about this? Since I don't know what it is, it's kind of hard to find more information about it. Any guidance would be greatly appreciated. </p>
android
[4]
1,554,822
1,554,823
How does Python distinguish callback function which is a member of a class?
<p>Please look at the simple example:</p> <pre><code>class A: def __init__(self, flag): self.flag = flag def func(self): print self.flag a = A(1) b = A(2) callback_a = a.func callback_b = b.func callback_a() callback_b() </code></pre> <p>The result is:</p> <pre><code>1 2 </code></pre> <p>It runs as expected. But I have a question. In C, the callback function is passed as a pointer. In Python, it should have a similar way to do this, so the caller knows the address of the function. But in my example, not only the function pointer is passed, but also the parameter (self) is passed, because the same method of the same class prints different results. So my questions are:</p> <ol> <li><p>Does such a method in Python only has one copy in memory? My meaning is that the code of any method only has one copy, and in my example the method won't be cloned itself. I think it should have only one copy, but here I still make this question in order to get more inputs.</p></li> <li><p>I remember everything in Python is an object. So in my example, are there two function instances with different parameters but only one copy of code?</p></li> </ol>
python
[7]
2,599,897
2,599,898
Jquery replace not working for inner strings
<p>I need to replace <code>|||</code> from all the input fields using jquery. But it is only replacing the first item. I need to use regex but I don't know how to add that to the string.</p> <pre><code>$(document).ready(function() { $("#layerPaper").children("div").each(function() { $val = $(this).children('input:text'); $val.val($val.val().replace('|||', '\"')); }); }); </code></pre> <p>Thanks.</p>
jquery
[5]
4,435,035
4,435,036
iPhone - adding a CGPath to a NSMutableArray... how?
<p>When I need to add a integer to an array I use</p> <pre><code>[myArray addObject:[NSNumber numberWithInt:myInt]]; </code></pre> <p>but what about CGPaths? How do I add them to the array?</p> <p>I need something like</p> <pre><code>"[NSValue valueWithCGPath:myPath]"... ???!!! </code></pre> <p>any clues? thanks</p>
iphone
[8]
6,014,199
6,014,200
Authenticating google calendar using authToken
<p>How can I use an authToken string to manipulate a google calendar? I understand how to get the authToken, but I don't understand how to use the authToken to access google calendar...</p> <p>In the stackoverflow question below, the person says they append it to the url, but I just haven't been able to figure out where to put it...</p> <p><a href="http://stackoverflow.com/questions/1996686/authtoken-from-accountmanager-in-android-client-no-longer-working">AuthToken from AccountManager in Android Client No Longer Working</a></p> <p>Can anyone please help me? Thanks.</p>
android
[4]
5,226,922
5,226,923
Data structures using java
<p>Is it possible to implement data structures using java? If yes can u help me</p>
java
[1]
2,687,805
2,687,806
How to ensure that one time is always less than another
<p>I've got two times that need to be stored into a database. The time format is hh:mm:ss with NO DATE. These times can be changed by the users on the system. One is a time on and the other is a time off. The time off should always be greater than the time on within a 24 hour cycle.</p> <p>Here is the part that I'm having trouble with. I don't want to limit the user to selecting times before midnight to keep everything in the same "daily" cycle so I'd like to be able to logically determine if the users' times are simply within a 24 hour time period and then test that the on time is always less.</p> <p>Can someone help me work through this? There are so many time and date functions that I really don't know which one(s) I need to do this; plus, I'm unclear on how I should test for this.</p> <hr> <p>I'm starting to think that there is no way to test for this without having a date included. Just the times is not enough.</p>
php
[2]
748,177
748,178
jquery, is it possible to store information in a variable, rather than an input field?
<p>I want to store the current page number in a jquery variable, but I am not sure if it is possible, so I am storing it in an input field. Am I doing it the most efficient way?</p> <pre><code>&lt;input type='hidden' id='current_page' /&gt; $('#current_page').val(0); </code></pre> <p>if page is changed,</p> <pre><code>function (newpage){ $('#current_page').val(page_num); } </code></pre>
jquery
[5]
333,874
333,875
identify end the edges of iframe using javascript or jquery
<p>I have an iframe which has a table structure with multiple rows and columns. I want to display tool tips when i hover over a cell. If the cell is at the right or bottom edge of the iframe, I would like to change the position of the tool tip. </p> <p>I want to be able to identify that edge of iframe so that I can change its position. How to identify it using jquery or javascript?</p>
jquery
[5]
2,440,922
2,440,923
java.lang.noclassdeffounderror for JComponent mock class
<p>I'm getting a java.lang.noclassdeffounderror when trying to create a mock class for Component using EasyMock. </p> <pre><code>private Component mockComponent; @SuppressWarnings("restriction") @Before public void setUp() { mockComponent = EasyMock.createMock(Component.class); } </code></pre>
java
[1]
4,534,971
4,534,972
catch & save outging sms to my app & the native app
<p>iv`e created an SMS app with a db that saves almost all of the messages.</p> <p>the problem starts when i want to save (1) my app outgoing messages to the native SMS app - the mmssms.db &amp; the (2) outging native SMS messages to my app db.</p> <p>i searched all over and failed to find a proper example for that question,especially for the second one.</p> <p>iv`e found that its all about the ContentResolver like this:</p> <p><a href="http://stackoverflow.com/questions/2735571/detecting-sms-incoming-and-outgoing">Detecting SMS incoming and outgoing</a></p> <p>but i cant figure how.</p> <p>please help me :)</p> <p>tanks!</p> <p>EDIT: </p> <p>the aswer for the (1) question is : <a href="http://stackoverflow.com/questions/7763575/android-updating-the-sent-box-afer-sending-an-sms">Android: Updating the sent box afer sending an sms</a></p> <p>still searching for the (2) answer.</p>
android
[4]
3,365,721
3,365,722
Redirection to url with space %20
<p>I have created this code in php</p> <pre><code>$cpage = ''.$_POST['page'].''; header("Location:$cpage/chat"); </code></pre> <p>It redirects to a page <code>10%20/chat</code> and not <code>10/chat</code>.</p> <p>What's the problem?</p>
php
[2]
4,291,367
4,291,368
How to find Uri when I have string path of .3gp file?
<p>I have path (String path) to my file .3gp on phone and I want to get Uri from that path so I can play in VideoView. I have tried like </p> <pre><code> video= Uri.fromFile(new File(path))); videoView.setVideoURI(video); videoView.start(); </code></pre> <p>but it doesn't work. can someone show me how to find Uri when I have string path ?</p>
android
[4]
5,332,531
5,332,532
Need to convert exe file to JAR file
<p>I have one exe file, that is packed by Tool Jar2exe. Can anyone help me to Convert it to jar file or is it possible or not ? Below is the link of that file .</p> <p><a href="http://www.mediafire.com/?eh7dmuy9vxd9m3w" rel="nofollow">http://www.mediafire.com/?eh7dmuy9vxd9m3w</a></p>
java
[1]
763,862
763,863
What does empty string contain in C++
<p>Following code </p> <pre><code>#include &lt;stdio.h&gt; int main( int argc, char** argv ) { const char *s = ""; if (s == '\0') { int x = 0; } return 0; } </code></pre> <p>It does not go in the loop. Why ? , </p>
c++
[6]
2,850,902
2,850,903
Javascript Game Engine
<p>I'm trying to write a javascript game engine myself. I did something like this; How do you think can make it more useful? Waiting for suggestions. thanks</p> <p>How do I write less than this initial code, for example?</p> <pre><code> var jSgame = function(w,h,bgcolor){ if(bgcolor == undefined){ bgcolor = '#ccc'; } this.bgcolor = bgcolor; if(w==undefined){ w = 400; } if(h==undefined){ h = 200; } this.w = w; this.h = h; this.start = function(){ var c = document.createElement('canvas'); if(c){ c.style.backgroundColor = this.bgcolor; c.width = this.w; c.height = this.h; document.body.appendChild(c); this.ctx = c.getContext('2d'); } } } jSgame.prototype.draw = function(x,y,bgcolor){ a = new jSgame(x,y,bgcolor); a.start(); this.ctx = a.ctx; this.rect=function(x,y,r,animate,clear,physics){ ctx = this.ctx; var dx = 1; if(!animate||!clear){ ctx.fillRect(x,y,r,r); }else if(animate&amp;&amp;clear){ setInterval(function(){ ctx.clearRect(0,0,a.w,a.h); ctx.fillRect(x,y,r,r); x += dx; if(physics){ if(x+dx&gt;a.w-r){ dx=-dx; }else if(x+dx&lt;0){ dx=-dx; } } },1); } } } Game = new jSgame(); Draw = new Game.draw(400,400,'#ccc'); Draw.rect(10,10,10,true,true,true);​ </code></pre>
javascript
[3]
3,126,585
3,126,586
Problem finding/reading a file
<p>I'm trying to develop a small application, where I was given a JSON file, and I have to extract data from it. As I understood a JSON object takes a string argument, thus I'm trying to access a file and write the data from it to a string. I've placed that file in a "JSON file" folder, and when I try to read the file, it throws me a file not found exception. I've tried several ways to find a path to that file, but every attempt was for vain. It might be that I'm extracting the path wrong, or might be something else, please help me. Thanks in advance. here is the code of finding the path:</p> <pre><code> try { path = Environment.getRootDirectory().getCanonicalPath(); } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } File jFile = new File(path + /"JSON file/gallery.json"); </code></pre> <p>here is the code for reading from a file :</p> <pre><code> String str =""; try { BufferedReader in = new BufferedReader(new FileReader(jFile)); while ((str += in.readLine()) != null) { } in.close(); } catch (IOException e) { e.getMessage(); } return str; </code></pre> <p>Here more specification: I want to take the data from the file in order to do that : JSONObject(jString). when I extract the path of json file I create a file with the path and pass it to the function that reads from the file, and there it throws me a file not found exception, when I try to read from it. The file does exists in the folder (even visually - I've tried to attach an image but the site won't let me, because I'm new user) I've tried to open the file through the windows address bar by typing the path like that: C:\Users\Marat\IdeaProjects\MyTask\JSON file\gallery.json and it opens it. </p>
android
[4]
2,076,598
2,076,599
Google Chrome, text input value
<p>I have an authentication system in my program, and when I did 'Save Password' with google chrome, it automatically fills the username and password text boxes with the last username and password that was saved.</p> <p>However, when I try to check the value of the content of the username input box, using:</p> <pre><code>alert($('#user_email').val()); </code></pre> <p>Google Chrome gives me blank output, while Firefox gives me the value in the text box. Is there a way to get this value for Google Chrome as well? Maybe using something other than <strong>.val()</strong>?</p> <p>Thanks.</p>
jquery
[5]
1,283,326
1,283,327
ASP.NET Web Site vs ASP.NET Web Application
<blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="http://stackoverflow.com/questions/475938/what-is-the-difference-between-web-application-and-website-in-asp-net">What is the difference between web application and website in asp.net?</a><br> <a href="http://stackoverflow.com/questions/398037/asp-net-web-site-or-web-application">ASP.NET: Web Site or Web Application?</a> </p> </blockquote> <p>To start a new ASP.NET project in Visual Studio 2008 we are presented with two options to go about creating a website,you can either create it as a new ASP.NET Web Site(File > New Website > ASP.Net website) or an ASP.NET Web Application(File > New Project > ASP.net Web Application).</p> <p>What's the difference between these two project types? Has got to do anything with the security or performance?</p> <p>Im using Visual Web Developer 2008 Express edition.Does the Visual Studio Professional Edition have additional options to create ASP.Net Project?</p> <p>Thank You</p>
asp.net
[9]
5,339,433
5,339,434
variable (form.onsubmit) still null after assignment
<pre><code>function registerForm(formName){ if(!formName) return; var form = document[formName]; form.onSubmit = function(){ console.log('I am the onsubmit function'); }; console.log('onsubmit set: ' + form.onsubmit); } window.onload = function(){ registerForm('myform'); }; </code></pre> <p>This is a snippet of a larger section of code.</p> <p>As you can see, I am assigning form.onsubmit to equal an anonymous function</p> <p>However, the assignment does not work.</p> <p>Replacing the assignment with form.onsubmit = 1 does not work either - the value is still null afterwards.</p> <p>Any help appreciated. Thanks.</p>
javascript
[3]
1,260,890
1,260,891
java.lang.reflect.InvocationTargetException in Java
<pre><code>if(locs!=null) { System.out.println("location are not null"); Iterator ite = locs.iterator(); DefaultComboItem locObj = null; ArrayList locCode = null; String cod=null; String name=null; while(ite.hasNext()) { locCode = (ArrayList) ite.next(); Iterator iter = locCode.iterator(); while(iter.hasNext()) { cod=(String)iter.next(); System.out.println("Code="+cod); name=(String)iter.next(); System.out.println("name="+name); locObj = new DefaultComboItem(cod, name); colRet.add(locObj); } } } </code></pre> <p>on executing above code i am getting "java.lang.reflect.InvocationTargetException" getting this exception on cod=(String)iter.next(); line, because iter.next(); returns bigDecimal value and i am converting into String variable</p> <p>Please help me</p>
java
[1]
3,983,109
3,983,110
ASP.NET, refresh dropdownlist2 when dropdownlist1 selection changes?
<p>I have two databound dropdownlist controls. The first one (dropdownlist1) pulls directly from a table. The second one (dropdownlist2) also pulls from a table, but uses the selected value from dropdownlist1 in it's WHERE clause.</p> <p>How do I update/refresh dropdownlist2 after the user makes a selection in dropdownlist1? (Using VB if done by code)</p> <p>I've tried setting the "Auto Postback" property of dropdownlist1 to "true" and ultimately, this approach works. The only problem is, if I keep changing the selection in dropdownlist1, the selections available in dropdownlist2 are duplicated.</p> <p>Both dropdownlist controls are contained within a CreateUserWizard control using template. I've tried using FindControl and then DataBind() on dropdownlist2 from the SelectedIndexChanged event of dropdownlist1, but no change occurs after a selection is made in dropdownlist1.</p> <p>Any ideas?</p> <p><strong>SelectedIndexChanged Event</strong></p> <pre><code>Protected Sub AssignedManager_SelectedIndexChanged(sender As Object, e As System.EventArgs) CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("AssignedSupervisor").DataBind() End Sub </code></pre> <p><strong>* Above, AssignedManager is the first dropdownlist and AssignedSupervisor is the second dropdownlist *</strong></p>
asp.net
[9]
5,824,574
5,824,575
method getInputStream() in HttpURLConnection in Android always failed
<pre><code>HttpURLConnection urlConn = (HttpURLConnection) new URL( "http://www.google.com").openConnection(); InputStream is = urlConn.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String inputLine = ""; while ((inputLine = br.readLine()) != null) { result += inputLine; } </code></pre> <p>When it comes to urlConn.getInputStream(), it fails. But the same code works in normal java project instead of Android project.</p> <p>And I find that in Android, when it runs the first statement, urlConn is:"libcore.net.http.HttpURLConnectionImpl:http://www.google.com"</p> <p>But in normal java project, it is "sun.net.www.protocol.http.HttpURLConnection:http://www.google.com"</p> <p>Thanks!!</p> <p>Exception stack:</p> <pre><code>11-21 21:14:01.750: I/System.out(20784): debugger has settled (1392) 11-21 21:14:56.380: W/dalvikvm(20784): threadid=1: thread exiting with uncaught exception (group=0x410e49d8) 11-21 21:14:56.420: E/AndroidRuntime(20784): FATAL EXCEPTION: main 11-21 21:14:56.420: E/AndroidRuntime(20784): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.network/com.example.network.MainActivity}: android.os.NetworkOnMainThreadException 11-21 21:14:56.420: E/AndroidRuntime(20784): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1969) 11-21 21:14:56.420: E/AndroidRuntime(20784): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1994) 11-21 21:14:56.420: E/AndroidRuntime(20784): at android.app.ActivityThread.access$600(ActivityThread.java:126) </code></pre> <p>I have added the INTERNET permission.</p>
android
[4]
3,584,344
3,584,345
C++::How to put different length arrays of const strings into common class
<p>Sorry, new to C++, converting from C, and have struggled to find a good way to do this...</p> <p>//Fragment follows</p> <pre><code>const char *List1[]={"Choice1", "Not a good choice", "choice3"}; //rom-able const char *List2[]={"Hello", "Experts", "Can", "You", "Help?"}; class ListIF{ private: int index; char *list; public: void GetValString(char *tgt,int len);//get parameter value as string max len chars void SetIndex(int n){index = n;}; int GetIndex(void){return index;}; }; </code></pre> <p>//end Fragment</p> <p>The problem is how to write the constructor so that I can "encapsulate" the lists inside the class, without getting heap bloat (embedded target). And then how to write the gettor so that we can see list[index] within the class.</p> <p>I am going daft trying to do something that seems obvious, so I am missing something?</p>
c++
[6]
1,085,665
1,085,666
Better cout a.k.a coutn;
<p>Guys would it be difficult to write coutn which would basically place newline symbol at the end of the input. While working with console (that's all I can do at the moment) I'm finding very tedious to write '\n' every time I want the line to be a new line.<br> Or maybe it is already implemented?</p>
c++
[6]
5,903,032
5,903,033
Does prototype really matter in JavaScript if the class will never be subclassed?
<p>So, in answering another question on this site, I wrote a class for someone to create a BitArray instance in JavaScript. The code I posted looked like this:</p> <pre><code>var foo = function(param1) { this._member = param1; this.getMember = function() { return this._member; }; this.setMember = function(val) { this._member = val; }; this.alertMember = function() { alert(this._member); }; foo.STATIC_CONSTANT = "some value"; } </code></pre> <p>One of the comments I received was a rather stern "You should absolutely add the methods to foo.prototype instead of this". If I take that criticism and apply it to the above, it turns the code into:</p> <pre><code>var foo = function(param1) { this._member = param1; } foo.prototype.getMember = function(){ return this._member; }; foo.prototype.setMember = function(val) { this._member = val; }; foo.prototype.alertMember = function() { alert(this._member); }; foo.STATIC_CONSTANT = "some value"; </code></pre> <p>My question is, what's the difference here between the two approaches assuming foo will never be subclassed? </p> <p>To be clear, I'm not advocating writing sloppy code - I credit the commentor with catching me being sloppy - but as I was conceeding to his correctness, it really did make me think - why should I prototype if I'm creating an effectively sealed class? </p> <p>Is there some performance or functional consequence I'm missing here? Or when a class won't be subclassed is using the prototype irrelevent?</p>
javascript
[3]
4,416,593
4,416,594
PHP dollar sign in strings
<p>I don't unserstand why PHP doesn't make replacements in strings containing dollar signs. Look at the following example:</p> <pre><code>&lt;?php error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE); $var = 1024; $str = '$var'; echo $str, '&lt;br&gt;', "$str"; </code></pre> <p>Output is <em>$var $var</em>. Why is it so? Everything is clear with first <code>echo</code> parameter, but I expected that the last parameter will give a different result (1024), because it contains dollar sign encapsulated by double quotes, so it should be interpreted as variable and replaced to 1024. Where am I going wrong?</p>
php
[2]
395,259
395,260
Parsing the integer part of string
<p>I have a string which could be entered as <code>{n}d {n}h {n}m {n}s</code> where <code>{n}</code> is a integer denoting the number of days, hours, min, sec. How would I extract this <code>{n}</code> number from the string?</p> <p>The user does not have to enter all 4 - d, h, m, s. He could only enter 4d which means 4 days or 5h 2s which means 5 hours and 2 sec. </p> <p>Here's what I have. Definitely there should be a better way to do this. Also, does not cover all cases. </p> <pre><code>int d; int m; int h; int sec; string [] split = textBox3.Text.Split(new Char [] {' ', ','}); List&lt;string&gt; myCollection = new List&lt;string&gt;(); foreach (string s in split) { d = Convert.ToInt32(s.Substring(0,s.Length-1)); h = Convert.ToInt32(split[1].Substring(1)); m = Convert.ToInt32(split[2].Substring(1)); sec = Convert.ToInt32(split[3].Substring(1)); } dt =new TimeSpan(h,m,s); </code></pre>
c#
[0]
4,807,800
4,807,801
Determining if the screen gets too small to display the page
<p>Is there a way to detect when the user resizes the screen below a certain width and height and show a div with a message (in a div) saying the window has become too small to properly display the page?</p>
jquery
[5]
3,740,276
3,740,277
parse nested xml into php
<p>Hi all i have an xml file e.g</p> <pre><code>&lt;recipe&gt; &lt;id&gt;abc&lt;/id&gt; &lt;name&gt;abc&lt;/name&gt; &lt;instructions&gt; &lt;instruction&gt; &lt;id&gt;abc&lt;/id&gt; &lt;text&gt;abc&lt;/text&gt; &lt;/instruction&gt; &lt;instruction&gt; &lt;id&gt;abc2&lt;/id&gt; &lt;text&gt;abc2&lt;text&gt; &lt;instruction&gt; &lt;instructions&gt; &lt;recipe&gt; </code></pre> <p>on my php file i use </p> <pre><code>$url = "cafe.xml"; // get xml file contents $xml = simplexml_load_file($url); // loop begins foreach($xml-&gt;recipe as $recipe) { code; } </code></pre> <p>but it only retrieve the recipe id and name so how can i retrieve the instructions.</p>
php
[2]
3,501,160
3,501,161
how to validate password
<p>how to validate password> please explain briefly </p>
asp.net
[9]
2,541,768
2,541,769
C# Checking for presence of usb drive
<p>I am writing a file that extracts xml to obtain name of files and need to copy these files to the USB drive. The first 2 steps I able to do this. But questions is:</p> <ol> <li>How can I detect if there is a USB Drive</li> <li>Then detect which drive it is.</li> </ol> <p>Thanks!</p>
c#
[0]
1,094,788
1,094,789
PHP display problem
<p>How can I refresh a page and have the user data display in the text field the same way it was entered using PHP for example, Example 1 should display the same when refreshed and not look like Example 2.</p> <p>Example 1</p> <pre><code>&amp;amp;amp; </code></pre> <p>Example 2</p> <pre><code>&amp;amp; </code></pre>
php
[2]
5,538,439
5,538,440
How to set style for spinner programmatically?
<p>I have spinner with a style selection (I set the spinner style in <code>strings.xml</code>) and it's works well if I set the style in <code>main.xml</code>. But I want to know how to set the style programmatically in which the style already defined in <code>strings.xml</code>.</p> <p>Refer my code below</p> <p><strong>main.xml:</strong></p> <pre><code> &lt;Spinner android:id="@+id/PassengersSpinner1" android:layout_width="100dp" android:layout_height="40dp" android:layout_span="3" android:layout_marginTop="6dp" style="@style/SpinnerStyle" /&gt; </code></pre> <p><strong>strings.xml:</strong></p> <pre><code> &lt;style name="SpinnerStyle" parent="@android:style/Widget.Spinner"&gt; &lt;item name="android:background"&gt;@android:drawable/btn_default&lt;/item&gt; &lt;/style&gt; </code></pre> <p>Now, I want to know that how can I set this <code>strings.xml</code> programmatically without <code>main.xml</code>?</p>
android
[4]
24,257
24,258
PHP Org Chart image generation
<p>I'm trying to generate an organization chart in PHP; the classic "box" above another "box" connected by lines. I have all the employees in my organization saved in the following database structure...</p> <p>repots_to_table</p> <ul> <li>recordId (int)</li> <li>staffId (int)</li> <li>reports_to (int)</li> <li>type (char(1))</li> </ul> <p>Currently, I recursively start at the top (#400 who reports to themself). I don't really care how "wide" the image will be since the idea is I want to generate a final "image" to print or save. Can anyone help me figure out a good way (ideally with built in PHP image libraries) to make this happen?</p>
php
[2]
4,125,997
4,125,998
Clone working but can't clone it through ajax using jquery
<p>jquery cloning is working, for example,</p> <pre><code>$("#treeFile" &gt; ul:first &gt; li:first ul &gt; *).clone().appendTo("#dummyTree"); </code></pre> <p>However when attempting to send this clone to a post ajax, the file is empty...</p> <pre><code>var cloneTree = $("#treeFile" &gt; ul:first &gt; li:first ul &gt; *").clone(); $.post("tree.php", cloneTree); </code></pre> <p>When viewing firebug, this http request was successful but when viewing the file on the service file system, its empty...</p>
jquery
[5]
191,205
191,206
Intializing ofstream in class
<p>I don't want to construct ofstream in main(). Here is what I do but it does not compile:</p> <pre><code>#include &lt;fstream&gt; using namespace std; class test { private: ofstream &amp;ofs; public: test(string FileName); void save(const string &amp;s); }; //---------------- test::test(string FileName) : ofs(ofstream(FileName.c_str(),ios::out)) { } //---------------- void test::save(const string &amp;s) { ofs &lt;&lt; s; } //---------------- //Provide file name and to-be-written string as arguments. int main(int argc,char **argv) { test *t=new test(argv[0]); t-&gt;save(argv[1]); delete t; } test.cpp: In constructor ‘test::test(std::string)’: test.cpp:13: error: invalid initialization of non-const reference of type ‘std::ofstream&amp;’ from a temporary of type ‘std::ofstream’ </code></pre> <p>How to fix the code? Thank you in advance!</p>
c++
[6]
4,391,173
4,391,174
Updated to Android sdk r15, but now I can't use anything
<p>I'm not sure what I did wrong, but I'll try and give as much information as I can.</p> <p>Yesterday, I updated a few things in the manager, with one of them being sdk r15. Now, I'm not sure what was updated because I believe there is the sdk 15 and the adt plugin r15. In any case, one of them was updated. I didn't restart and continued to work without any problems. However, today my emulator stopped loading the app I was testing. I restarted eclipse and was thrown this prompt:</p> <blockquote> <p>"This Android SDK requires Android Developer Toolkit version 14.0.0 or above. Current version is 12.0.0.v201106281929-138431. Please update ADT to the latest version."</p> </blockquote> <p>Currently, all of my projects have error symbols next to them. I then proceed to click the AVD manager, which I'm given a prompt that says: </p> <blockquote> <p>"The location of the Android SDK has not been setup in Preferences."</p> </blockquote> <p>I go to Preferences and see that the sdk path is pointing to the correct folder. I haven't changed anything so I dont see how the path could be a problem. </p> <p>What happened? How can I get things working again? Perhaps, the update did not install everything properly? </p> <p>EDIT: By the way, I "apply" and "ok" are greyed out in Preferences no matter which folder I choose.</p>
android
[4]
4,396,359
4,396,360
Passing form name and form object names to functions
<p>I'm having trouble understanding the workings of Javascript...I want to pass a form name and the submit button name so that the function can evaluate a passed value and either enable or disable the submit button. </p> <p>It works if I explicitly use the names but I'd like it to work dynamically. Unfortunately I just am not understanding how to correctly use these arguments.</p> <p>Right now the first document statement works (form name and button name are used), why doesn't the second, where arguments are used? I know from the alert that the form name isn't correct and can't be used as is but this won't work even if I explicitly name the form but use the passed button name which does appear correct.</p> <p>I know this must be javascript 101 but I run into this time and again and am just not getting what's what. Anyone willing to explain this to me?</p> <pre><code>&lt;script type="text/javascript"&gt; function aTest(formName,objName,val){ if (val&lt;5){ document.aForm.aBtn.disabled=false; alert(formName+" - "+objName); } else { document.formName.objName.disabled=true; } }//end function aTest(formName,objName) &lt;/script&gt; &lt;form name="aForm"&gt; &lt;input name="testFld" type="text" onBlur="aTest(this.form,'aBtn',this.value)"&gt; &lt;input name="aBtn" type="submit" value='submit'&gt;&lt;/form&gt; </code></pre> <p>Thank you for your kind attention!</p>
javascript
[3]
915,593
915,594
How to kill all running applications in android?
<p>I want to kill all running applications in android .so for this task , i implemented following code. But it is not working .App still remains in running.</p> <pre><code>ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); for (RunningAppProcessInfo service : manager.getRunningAppProcesses()) { Log.i("process name " , service.processName); android.os.Process.killProcess(service.pid); } </code></pre> <p>So where does i make mistake in code ? Is there any help ?</p>
android
[4]
3,586,416
3,586,417
Jquery problem with IE working fine in FF
<p>Hello i have this code that works perfect in Firefox but in IE 8 doesn't work and doesn't give me any error ?!</p> <pre><code>$(".shp_div").change(function () { var str = ""; $("select option:selected").each(function () { var countprod =parseInt($("#countprod").val()); var str2 = $(this).val(); str2_array = str2.split('|'); var cost = parseInt(str2_array[0]); var cost_extra = parseInt(str2_array[1]); if ($("#countprod").val()&gt;1) { str = parseInt(((countprod-1)*cost_extra) + cost); } else{ str = cost; }}); $(".csq_item2").text(str); var total =parseInt($("#subtotal").val()); var shipping=parseInt(str + total); $(".price_total").text(shipping); }) .change(); </code></pre> <p>In order to get "full picture" please go at : <a href="http://poshsunglasses.net/21-Bottega_Veneta-B.V.88.html" rel="nofollow">http://poshsunglasses.net/21-Bottega_Veneta-B.V.88.html</a> and add to cart the prod and then in the cart page try to select the Shipping country in FF make the calculation in IE no.</p> <p>thank you</p>
jquery
[5]
3,600,417
3,600,418
inject JS code into a textarea
<p>I am trying to show some JS code in a textarea. The code is generated with JS so I am injecting it into the textarea with JS. However, using the <code>&lt;script&gt;</code> tags, causes the script to execute. I thought using <code>&amp;lt;</code> would solve this, but this is simply displaying <code>&amp;lt;</code> instead of <code>&lt;</code>.</p> <p>Any suggestions how I can do this?</p> <pre><code>$('myTextarea').set('value', '&lt;script&gt;alert('do something');&lt;/script&gt;'); </code></pre>
javascript
[3]
3,791,416
3,791,417
Customizing compare in bsearch()
<p>I have an array of addresses that point to integers ( these integers are sorted in ascending order). They have duplicate values. Ex: 1, 2, 2, 3, 3, 3, 3, 4, 4......</p> <p>I am trying to get hold of all the values that are greater than a certain value(key). Currently trying to implement it using binary search algo -</p> <pre><code>void *bsearch( const void *key, const void *base, size_t num, size_t width, int ( __cdecl *compare ) ( const void *, const void *) ); </code></pre> <p>I am not able to achieve this completely, but for some of them.</p> <p>Would there be any other way to get hold of all the values of the array, with out changing the algorithm I am using?</p>
c++
[6]
3,098,274
3,098,275
Checkbox server/client events
<p>I have a checkbox in repeater control. on changing it's bit value, it should prompt the alert message like do u wish to delete? and if yes is selected, the onselectedchange server event should be fired.</p> <p>Right now. on clicking the checkbox i am using onclick event to fire the prompt but it is not able to fire the server event. </p> <p>here is my code</p> <pre><code>&lt;script language="javascript" type="text/javascript"&gt; function CheckedChange() { if (confirm('Are you sure you want to delete?')) return true; else return false; } &lt;/script&gt; &lt;asp:Repeater ID="repQuestion" runat="server" onitemcommand="repQuestion_ItemCommand" onitemdatabound="repQuestion_ItemDataBound"&gt; &lt;ItemTemplate&gt; &lt;table width="100%" cellspacing="0" cellpadding="0"&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:CheckBox onclick="return CheckedChange();" ID="delete" runat="server" Checked='&lt;%#DataBinder.Eval(Container.DataItem, "IsDeleted")%&gt;' OnCheckedChanged="chkdelete_Click" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; </code></pre>
asp.net
[9]
960,372
960,373
Sending the iphone camera captured images to the web service and getting response?
<p>Hey guys I was wondering if anyone had some sample code for enabling the camera for the iphone. I want to be able to Send the captured image to webservice.</p>
iphone
[8]
1,201,802
1,201,803
Convert video to GIF
<p>I'm building an iOS app which requires me to allow the users to record a 15sec clip (with <code>UIImagePickerController</code> for example) and then convert it into an animated GIF. How could I achieve this? Is there any library/framework available for such task?</p> <p>Thanks!</p>
iphone
[8]
2,751,375
2,751,376
How to bookmark and send a class/activity to a bookmark page in android app?
<p>I am trying to make an app which consists of only text. Every page(xml) is different. Now I want to make a bookmark page for the user to bookmark his/her favorites. I succeeded making a bookmark page which is activated with a button on the home-screen, I also have a bookmark button on every text page, but I can't figure out how I can send or reveal my bookmarked page/text on the bookmark page.</p> <p>Can anyone please help me?</p>
android
[4]
2,437,555
2,437,556
Javascript help needed - which variable is return empty?
<p>Hi I would like to know how do I add an error check to below mentioned code...I mean how do I check if this code return empty or not?? if this returns empty then I would give a message "Not Found".. How do I do That??</p> <pre><code>google.load('search', '1'); var blogSearch; function searchComplete() { // Check that we got results document.getElementById('content').innerHTML = ''; if (blogSearch.results &amp;&amp; blogSearch.results.length &gt; 0) { for (var i = 0; i &lt; blogSearch.results.length; i++) { // Create HTML elements for search results var p = document.createElement('p'); var a = document.createElement('a'); a.href = blogSearch.results[i].postUrl; a.innerHTML = blogSearch.results[i].title; // Append search results to the HTML nodes p.appendChild(a); document.body.appendChild(p); } } } function onLoad() { // Create a BlogSearch instance. blogSearch = new google.search.BlogSearch(); // Set searchComplete as the callback function when a search is complete. The // blogSearch object will have results in it. blogSearch.setSearchCompleteCallback(this, searchComplete, null); // Set a site restriction blogSearch.setSiteRestriction('blogspot.com'); // Execute search query blogSearch.execute('1974 Chevrolet Caprice'); // Include the required Google branding google.search.Search.getBranding('branding'); } // Set a callback to call your code when the page loads google.setOnLoadCallback(onLoad); </code></pre>
javascript
[3]
1,306,436
1,306,437
body runat="server" causing compilation error
<p>In a Master Page I have the following markup</p> <pre><code>&lt;body id="body" runat="server"&gt; </code></pre> <p>I have set <code>runat="server"</code> because I need to be able to access the body element in code-behind.</p> <p>I would now like to add a JavaScript function call to the <code>body onload</code> event, like this:</p> <pre><code>&lt;body id="body" runat="server" onload="someJavaScriptFunction();"&gt; </code></pre> <p>However, this is giving my a compile error, with a message of "Cannot resolve symbol someJavaScriptFunction();". If I run the application I get an error telling me</p> <pre>Compiler Error Message: CS1026: ) expected</pre> <p>What is going on here? <code>onload</code> is a client-side event, so why does the ASP.NET compiler care about this?</p>
asp.net
[9]
1,842,452
1,842,453
How can a type that is used only in one compilation unit, violate the One Definition Rule?
<p>I was told that these types, that are visible in there own unique translation unit, were in violation of the One Definition Rule. Can someone explain this?</p> <pre><code>//File1.cpp #include "StdAfx.h" static struct S { int Value() { return 1; } } s1; int GetValue1() { return s1.Value(); } //File2.cpp #include "StdAfx.h" static struct S { int Value() { return 2; } } s2; int GetValue2() { return s2.Value(); } // main.cpp #include "stdafx.h" extern int GetValue1(); extern int GetValue2(); int _tmain(int argc, _TCHAR* argv[]) { if( GetValue1() != 1 ) throw "ODR violation"; if( GetValue2() != 2 ) throw "ODR violation"; return 0; } </code></pre> <p>I know how to fix the problem. As per the title, I was looking to why it was a ODR violation. How does it violate: "In any translation unit, a template, type, function, or object can have no more than one definition."? Or maybe it violates a different part of the rule.</p>
c++
[6]
3,254,186
3,254,187
difference between final int and final static int
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2070669/java-is-using-a-final-static-int-1-better-than-just-a-normal-1">java: is using a final static int = 1 better than just a normal 1?</a> </p> </blockquote> <p>Well I'd like to know what difference between: final int a=10; and final static int a=10; when they're the member variables of a class, they both hold the same value and cannot be changed anytime during the execution. Is there any other difference than that the static variable is shared by all the objects and a copy is created in case of non-static variable?</p>
java
[1]
260,870
260,871
Retrieving element with no name or id
<p>I am trying to write some code to accomplish something very simple. I have never worked with a PayPal button before, which is causing some difficulty. </p> <p>I have been able to simulate a button click before, using document.getElementById or document.getElementsByName(), however, the form I am trying to submit above does not have a name, or an id, so I do not know how to refer to it in my code. </p> <p>I am trying to write a short chrome extension using Javascript that will find the paypal form/button on the page (that I do not own or have control over), and submit it without me having to click it. Any guidance/links would be much appreciated. </p>
javascript
[3]
1,323,698
1,323,699
Cast to not explicitly implemented interface?
<p>Let's say you define some arbitrary interface:</p> <pre><code>public interface IInterface { void SomeMethod(); } </code></pre> <p>And let's say there are some classes that happen to have a matching public interface, even though they do not "implement IInterface". IE:</p> <pre><code>public class SomeClass { public void SomeMethod() { // some code } } </code></pre> <p>is there nevertheless a way to get an IInterface reference to a SomeClass instance? IE:</p> <pre><code>SomeClass myInstance = new SomeClass(); IInterface myInterfaceReference = (IInterface)myInstance; </code></pre> <p>Thanks</p>
c#
[0]
4,800,374
4,800,375
Unable to switch on String in JRE7
<p>I'm on jre7 and I still can't switch on Strings. I installed jdk7 update 1 and pointed Eclipse to it but still no luck. Any idea what I'm doing wrong? Thank you.</p> <p>Here is a the code:</p> <pre><code>String code = "something"; switch(code) { case "xxx": dosomehting(); break; default: dosomethingelse(); break; } </code></pre> <p>The error I get: Cannot switch on a value of type String. Only convertible int values or enum constants are permitted.</p>
java
[1]
397,880
397,881
selecting resources from gui instead of using XML
<p>I'm able to select android provided colors in xml using <code>@android:color/black</code> etc but I'm unable to find <code>android</code> option in <code>Reference Chooser</code> GUI.Is there a way?</p> <p>I remember that I found <code>android</code> in Reference chooser sometime back.</p>
android
[4]
4,520,677
4,520,678
Swapping pointer to pointer
<p>In this program I'm writing, I'm using 2 matrices declared as pointer to pointer. Initially, matrix B is equal to matrix A, and all the changes are being made to matrix B (I need to not modify the values in A because I'm using those values to compute something else and if I directly modify it I practically get the wrong result). In the end, I need to swap the values in the two matrices. My program is already running and compiling, but to swap the matrices I've used </p> <pre><code>for(i=0;i&lt;n;++i) for(j=0;j&lt;n;++j) A[i][j]=B[i][j]; </code></pre> <p>I know that's not the best method, so I was wondering whether there's a way to swap my matrices by pointers. I've already tried to do it myself. but I'm new to C++ programming and I cannot seem to manage to do it right :(. </p> <p>This is a sketch of my code: </p> <pre><code>void swap(int **A, int **B){ ? } main (){ int **A, **B; *code* swap(A,B); } </code></pre>
c++
[6]
3,435,539
3,435,540
i have a button whose background i want to be transperant in android
<p>i have to make a buttons background transparent , how do i go aboutit?</p> <p>i know there is a constant transparent which i found <a href="http://developer.android.com/reference/android/R.color.html#transparent" rel="nofollow">here</a>, but i don't know how to use it.</p> <p>thank you in advance.</p>
android
[4]
5,460,446
5,460,447
C++: integer array of 1 and 0s to original character
<p>I have int arrays of 1s and 0s like-</p> <pre><code>01101000 01100101 01101100 01101100 01101111 </code></pre> <p>which is bit conversion of "hello". I want to convert it back to character array like-</p> <pre><code>01101000 -&gt; h 01100101 -&gt; e 01101100 -&gt; l 01101100 -&gt; l 01101111 -&gt; o </code></pre> <p>can you guys give C++ code snippet for the same ?</p>
c++
[6]
2,131,985
2,131,986
whats the significance between having the java class containing the main method setup as public and not
<p>When I started learning Java I too started with the ubiqutous Hello world app. Which is more or less like :</p> <pre><code>public class MyClass { public static void main(String args[]){ //some code here.... } } </code></pre> <p>Its been many years since my tryst with Java but recently I was confronted by a beginner with a problem : Her class file wouldn't run even though she was able to compile correctly.</p> <p>After looking at her code the first thing I noticed was that is didn't have the public access specifier on the class with the main method. I immediately mocked her on that slip up and went about "fixing" it by adding the public access modifier. The joke was on me offcourse as that didn't make any difference either. I then realized that she was trying to execute the compiled class from a different directory from the one where the class file was. I changed to that dir and issued the java command and it ran immediately. </p> <p>This brings me to my question... Most hello world examples have the class setup with public access when its just as ok to not have that at all. So what difference does it make if at all for a class that contains the main method ? </p> <p>To help make it clearer as to what we were doing exactly here are the steps :</p> <p>We had the class in </p> <pre><code>c:\users\[usersname]\[my documents folder]\myprog.class </code></pre> <p>and we tried to run it from c:\ (as our working dir) . We did specify the full relative path expecting it to work. like so :</p> <pre><code>java users\[usersname]\[my documents folder]\myprog </code></pre> <p>Offcourse this just failed untill I changed into the documents folder making it the current working dir and issuing the command again like so</p> <pre><code>java myprog </code></pre> <p>So basically such a call makes sense when you have the class in a package resembling the folder structure prepended to its name. In this case the class is not in any package.</p>
java
[1]
2,786,083
2,786,084
how to make different user application out of same source code
<p>i have made an android application that retrieves data from internet and performs further operation on that data.</p> <p>i have 4 urls for retrieving data. so i want to make 4 different applications for 4 different urls, each application receiving data from one of the URL. and i also want to run all four application on the single device.</p> <p>now my problem is that when i uninstall one of the application all four application gets uninstall, and all the applications are showing the same data.</p> <p>Please help.</p> <p>Thanks in advance.</p>
android
[4]
3,227,473
3,227,474
Java constructor explanation please?
<p>I dont understand how a constructor works In the following code i know that we have a class, then two variables. When you create a variable you create a container for a value, so by declaring the variables x and y we created two containers, and they contain 0,0.</p> <p>why the constructor, why the a and b?</p> <pre><code>public class Point { public int x = 0; public int y = 0; //constructor public Point(int a, int b) { x = a; y = b; } } </code></pre>
java
[1]
3,525,431
3,525,432
How to Select Full Row in Repeater in asp.net
<p>Hi Experts How to Select Full Row in Repeater Control in asp.net I Have Right the following code</p> <pre><code>function SetSelectedModuleIdRow(rowId, objRepeater) { var rows = document.getElementById(objRepeater).getElementsByTagName("TR"); for (var j = 0; j &lt; rows.length; j++) { cells = rows[j].getElementsByTagName("TD"); for (var i = 0; i &lt; cells.length; i++) { cells[i].style.backgroundColor = '#ffffff'; } } var row = parseInt(rowId) + 1; arrCol = rows[row].getElementsByTagName("td"); for (var j = 0; j &lt; arrCol.length; j++) { arrCol[j].style.background = '#808080 '; } } </code></pre> <p>on ItemDatabound call this function.</p>
asp.net
[9]
132,058
132,059
function not working for jquery load() content tags?
<pre><code>$(function(){ $(".tiptip").tipTip(); }); </code></pre> <p>this tooltip function is working for all links.But it doesn't work for what are loaded through jquery load() function.</p> <p>I have experienced in live() function.I have used this function on content events(click,change,blur) loaded via load().</p> <p>But i don't know how to use this for content loaded via load().</p> <p>Please help me.</p>
jquery
[5]
206,241
206,242
Problem closing popup window
<p>I'm creating a popup window using <code>window.open</code> that can be closed later by the <code>opener</code> with a call to <code>close()</code> without problem, the problem is when the popup window navigates to a different url, then <code>close()</code> will do nothing.</p> <p>I'm using IE9.</p> <p>the code that I'm using to test is:</p> <pre><code>var popup = window.open($(this).attr("href"), "Popup", "width=550,height=300,toolbar=0,scrollbars=0,status=0,resizable=0,location=0,menuBar=0"); setTimeout(function () { popup.close(); }, 1000); </code></pre> <p>if the popup window doesn't navigate to another url, it closes, but if it does, it won't close...</p> <p>thanks!</p>
javascript
[3]
2,404,870
2,404,871
It only displays one message rather choosing correct message to display
<p>I am trying to determine questions answered correctly and questions answered incorrectly. If answered correctly then display "Fully Correct" else if incorrect then display the "Incorrect" message. Problem is no matter if correct or not it always displays that question is answered incorrectly.</p> <p>Below is code:</p> <pre><code> $check = true; foreach ($studentData['questions'] as $questionId =&gt; $questionData) { if($questionData['answer'] == $questionData['studentanswer']) { echo '&lt;td width="30%" class="studentanswer green"&gt;&lt;strong&gt;'.htmlspecialchars($questionData['studentanswer']).'&lt;/strong&gt;&lt;/td&gt;' . PHP_EOL; } else { echo '&lt;td width="30%" class="studentanswer red"&gt;&lt;strong&gt;'.htmlspecialchars($questionData['studentanswer']).'&lt;/strong&gt;&lt;/td&gt;' . PHP_EOL; $check = false; } if($check) { echo '&lt;p class="green"&gt;&lt;strong&gt;Fully Correct&lt;/strong&gt;&lt;/p&gt;'; } else { echo '&lt;p class="red"&gt;&lt;strong&gt;Not Correct / Not Fully Correct&lt;/strong&gt;&lt;/p&gt;'; } } </code></pre>
php
[2]
1,244,321
1,244,322
$(this +"selector") ? $("img",this) possible?
<p>I'm trying to "select" a img inside a $(this) selector. I know I can find it by using <code>.find('img')</code> but is this possible:</p> <p><code>$("img",this)</code> ?</p> <p>What's the most optimal way to do this?</p> <p>Originally code</p> <pre><code>&lt;a class="picture" href="test.html"&gt; &lt;img src="picture.jpg" alt="awesome"&gt; &lt;/a&gt; </code></pre>
jquery
[5]
1,414,530
1,414,531
how to resolve Undefined index error?
<p>hey guys i got following error Undefined index: hname in C:\Temp\5Aug2010\job.php on line 38</p> <p>this error occur in insert command i use </p> <pre><code>'".mysql_real_escape_string($_POST['hname'])."' </code></pre> <p>where hname is a textbox field on form</p> <p>if i use</p> <pre><code>'".mysql_real_escape_string((isset($_POST['hname'])))."' </code></pre> <p>then error will gone but in database it show empty field.</p>
php
[2]
5,032,740
5,032,741
How do I override __getattr__ in Python without breaking the default behavior?
<p>I want to override the <code>__getattr__</code> method on a class to do something fancy but I don't want to break the default behavior.</p> <p>What's the correct way to do this?</p>
python
[7]
2,960,702
2,960,703
Make a piece of heap memory read-only
<p>If I have a database application in C++. When the data size is small, it's easy to debug for bugs. But when the data size becomes huge, and relationship becomes complex, the bug is very hard to debug, or hard to find the root cause of it. Sometimes the callstack can't tell you enough information to find the root cause, because the memory has been collapsed. It's very easy the memory of one component is written by other component. Only when the first component visit that memory, we met the crash, but it's too late.</p> <p>The difficulty to find the root cause is proportional to the size of the handling data.</p> <p>I am wondering if there is any tricks to predicate the risk, and protection code for avoid illegal memory written.</p> <p>C++ pointer is a powerful tool, but it's also the high risk to use it. Any code could use the pointer to write/update the memory anytime. When one code write a memory, no other class object know it unless the class visit that memory,then find the value is already invalid, crashed.</p> <p>If A hold a pointer to B, then some code write that memory to make the value to C. Then when A use the B pointer to do something, invalid pointer.</p> <p>I want to know, maybe it's impossible, if there some way to avoid this situation. Could we add some protection code there.</p> <p>One method I thought could be is I could make the memory to be writable before change, after change make it readable. So other code can't write it, otherwise crash. This would help me to find the issue earlier.</p> <p>Is there some way to make a piece of heap memory read-only?</p> <p>Platform is windows. I hope I could use some switch in the code to control it's access right.</p>
c++
[6]
82,193
82,194
javascript function - the correct way to do this
<p>Hi all and thanks for looking,</p> <p>What is the correct way to do this:</p> <pre><code>&lt;script language="javascript"&gt; function flag(nation) { this.nation=nation; document.getElementById("flag").innerHTML="&lt;img src='images/flags/'+nation+'.jpg'&gt;"; } &lt;/script&gt; </code></pre> <p>with this in the link tags: onClick="flag(scotislands)"; and the image name being scotislands.jpg</p> <p>Many thanks, B.</p>
javascript
[3]
2,494,840
2,494,841
JQuery Load() function
<pre><code>$(document).ready(function(){ $("#btnLoad").click(function(){ $('#div1').load('test.txt', {}, fnLoad()); }); }); function fnLoad() { // How can I load the content of &lt;div id="div1" /&gt; into a variable here? } </code></pre> <p>In fact, I want to work with the variable instead of div1.innerHTML.</p>
jquery
[5]
4,193,812
4,193,813
header location delay
<p>I have the following php code which I want to add a delay too:</p> <pre><code>&lt;?php echo "Message has been sent."; header("Location: page2.php", true, 303); exit; ?&gt; </code></pre> <p>The above code happens too fast so I can't see the message:</p> <p>I have tried:</p> <pre><code>&lt;?php sleep(5); echo "Message has been sent."; header("Location: page2.php", true, 303); exit; ?&gt; </code></pre> <p>This doesn't display the message either, but it does sleep for 5 seconds, which is just a waste of time.</p> <p>How do I get it to display a message for 5 second before redirecting?</p>
php
[2]
173,359
173,360
How can I make my function work with my if statement that changes my array
<p>In the script below I have an array. My array stores all the links, titles and descriptions from a web page. But I want to make sure that if there is no description, it will use the first 20 characters of a p tag using a function which works. Only problem is I have the jigsaw pieces and just can't seem to put them together, So I want my if statement to show that if the description is empty to use the function getWord instead of <code>getMetas()</code>.</p> <pre><code>function getMetas($link) { $str1 = file_get_contents($link); if (strlen($str1)&gt;0) { preg_match_all( '/&lt;meta.*?name=("|\')description("|\').*?content=("|\')(.*?)("|\')/i', $str1, $description); if (count($description) &gt; 1) { return $description[4]; } } } </code></pre> <p>Then my function goes here (<code>get_custom_excert</code>), but there is no need to see that as I know that works.</p> <pre><code>function getWord() { $html = file_get_contents($link); preg_match('%(&lt;p[^&gt;]*&gt;.*?&lt;/p&gt;)%i', $html, $re); $res = get_custom_excerpt($re[1]); } $outputs = array(); foreach ($links as $thisLink) { $output[] = array("link" =&gt; $thisLink, "title" =&gt; Titles($thisLink), "description" =&gt; getMetas($thisLink)); if ($output['description'] == null) { $output['description'] = getWord($res); } $outputs[] = $output; } print_r($output); </code></pre>
php
[2]
4,638,881
4,638,882
How to go from a selected button in a list to different activities or the same activity with different text
<p>So, I'm making my first android app and want to perform a simple task, but can't seem to figure out the way to do it. I simply want to go from a list view to a screen of differing information based on which button was pressed. The information is similar enough(ie. a title and block of text) that I think I can use the same activity for it all, but I don't know how to switch out the different information based on the user's selection. Should I make a separate activity for each button in the list, or can I have the first activity send context to a single next activity and somehow determine what xml code to use, and how do I do it?</p>
android
[4]
3,565,374
3,565,375
How do I hide a specific value from users in script source?
<p>I'm trying to hide a value in the PHP source code to prevent users from seeing the IP of a game server. The following code shows up in the source code:</p> <pre><code>"connection.host" : "888.888.888.888", "connection.port" : "30000", </code></pre> <p>So in this case I would like to hide 888.888.888.888 (Which is the IP of a server). Is there a way to encode this so the user won't see this? I heared about Ioncube but I'm looking for something else if that is possible.</p>
php
[2]
2,482,830
2,482,831
Hyperlink in a Datalist
<p>How do I create a hyperlink on a DataList in .NET?</p>
asp.net
[9]
4,461,599
4,461,600
Warning! Unknown device API version
<p>I am new to Android programming. I have created an app and I am deploying it on my android device with version 4.0.3. I have connected the device properly. Eventhough I get this warning. I have deployed successfully on previous occassions. I am really not able to understand why my device version is not getting detected now. Has my device cable got loose? plz help. Its urgent</p>
android
[4]