Sunday, April 3, 2011

Why does visual studio 2008 break my web page?

I have a aspx page that has a UpdatePanel and a asp timer. the timer tick is the trigger for the update panel.

If add anything to the update panel (even a space!) Visual Studio automagically adds the following

<Triggers>

<System.Web.UI.AsyncPostBackTrigger ControlID="tm1" EventName="Tick"></System.Web.UI.AsyncPostBackTrigger>
        </Triggers>

Even though the page has already registered the following (albeit in the same triggers section)

<Triggers>
<asp:AsyncPostBackTrigger ControlID="tm1" EventName="Tick" /> </Triggers>

So my questions are these

1) What is the difference between asp:AsyncPostBackTrigger and System.Web.UI.AsyncPostBackTrigger 2) Why does Visual Studio persist on adding this line which then breaks the page as it errors with the message System.Web.UI.UpdatePanelTriggerCollection must have items of type 'System.Web.UI.UpdatePanelTrigger'. 'System.Web.UI.AsyncPostBackTrigger' is of type 'System.Web.UI.HtmlControls.HtmlGenericControl'. 3) How can I stop this???

I am using Visual Studio 2008 targeting a .Net 2.0 Web application project.

From stackoverflow
  • Do you have the AJAX control library registered correctly for your project? Since you're targeting .Net 2.0, you'll need to add the AJAX library explicitly (it's not built in until .Net 3.5).

Detect in C if outputting to a terminal

I'm writing a C program for OS X and Linux, and I want to tweak the output based on whether or not it's going to a terminal. I know we've covered how to do this in a shell script, e.g. here:

http://stackoverflow.com/questions/911816/detecting-the-output-stream-type-of-a-shell-script

But how do I do it in a C program?

From stackoverflow
  • Use isatty():

    $ man isatty
    ISATTY(3)                  Linux Programmer's Manual                 ISATTY(3)
    
    NAME
           isatty - does this descriptor refer to a terminal
    
    SYNOPSIS
           #include <unistd.h>
    
           int isatty(int desc);
    
    DESCRIPTION
           returns  1  if  desc is an open file descriptor connected to a terminal
           and 0 otherwise.
    

    Since stdout is always file descriptor 1, you can do:

    if(isatty(1))
        // stdout is a terminal
    
  • if (isatty (1))
        fprintf (stdout, "Outputting to a terminal.");
    else
        fprintf (stdout, "Not outputting to a terminal.");
    

Get HttpWebResponse headers WITHOUT redirecting

I want to check if a particular page gets redirected or not. However, whenever I try this the headers I get back seem to be from the redirected page, not the initially requested page (and, in particular, the status is OK rather than the 302 I want to see).

Is there something I can set so that it won't automatically follow the redirects?

WebRequest request = WebRequest.Create(@"http://www.example.com/page.html");
request.Method = "HEAD";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.Redirect)
{
 ...
}
else
{
 MessageBox.Show("HTTP Code: " + response.StatusCode + "\r\n\r\n" + response.StatusDescription);
 return false;
}
From stackoverflow
  • HttpWebRequest.AllowAutoRedirect

    Gets or sets a value that indicates whether the request should follow redirection responses.
    ...
    If AllowAutoRedirect is set to false, all responses with an HTTP status code from 300 to 399 is returned to the application.

Sync Services Ado.net SyncSchema

hi I'm trying to build a custom ServerSyncProvider right now I'm trying to understand the GetScema Method

I'm trying to build a dataSet and associate it to SyncSchema class one of my table columns is a nvarchar(50) so im doing this:

DataColumn column = new DataColumn();

        column.ColumnName = "Name";

        column.DataType = typeof(String);

        column.MaxLength = 55;

        table.Columns.Add(column);

but turns out that on my client side, this column becomes nvarchar(1) any idea? tks a lot

From stackoverflow
  • Try this:

    column.ExtendedProperties.Add("ColumnLength", 50);

How to Connect SVN server in C++

Hi Guys I wanna connect svn server and download one file from svn to my computer location by using C++ and writing this program. How can i make this? Thanks

From stackoverflow
  • You have a few options:

    1. Set up WebDAV and use HTTP.
    2. Use the SVN client library and integrate using it.

    I've done both approaches in the past. The SVN client library is actually quite easy to use.

    Edit

    The subversion client library is described in Version Control with Subversion. Pay particular attention to Chapter 3 and Chapter 8. I started by grabbing a source snapshot from tigris.org and reading the source code for the command line client. It's in <root>/subversion/clients/cmdline. I found that the source is easy enough to follow.

    ibrahimyilmaz : do you know any tutorial concerned with this SVN Client Library?

Drupal Session User id for independent script

Hello,

I am creating a simple script say a.php. I know that drupal 6 creates a session etc. So in my a.php I am trying to print_r($_SESSION); but that doesnt seem to work. What is the best way to get the logged in users userid in my program?

Sorry I am new to drupal. Thank you for your time.

From stackoverflow
  • Drupal's cron.php is a perfect example of a "simple" php script that uses the libraries in Drupal's /includes directory. The key lines in that file are:

    include_once './includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    

    if you include those in your own code, your a.php file will have access to all of Drupal's context and libraries.

How do I set file permissions in Maven POM file

I need to set "execute" permissions on a file which is a part of the WAR project. Can I do this without resorting to Ant script?

From stackoverflow
  • Actually I found the answer in the "Maven: The Definitive Guide": http://www.sonatype.com/books/maven-book/reference/assemblies-sect-filesets.html

    Strange Google wasn't able to find it.

    victor hugo : Actually if you google "maven assembly plugin permission" the first result is the official reference from Maven http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html#class_fileSet, next time look at the assembly descriptor reference of the plugin
    Sasha O : Of course, if you know the magic word "assembly" :-)

Difference between numeric,float and decimal in sql server

Hi, I searched in google and also visited the

decimal and numeric and SQL Server Helper

to glean the difference between numeric , float and decimal datatypes and also to find out which one should be used in which situation.

For any kind of financial transaction, which one is prefered and why? e.g. for salary field

From stackoverflow
  • Thanks I got the answer from this site

    SQL SERVER – Difference and Explanation among DECIMAL, FLOAT and NUMERIC

  • Decimal has a fixed precision while float has variable precision.

    EDIT (failed to read entire question): Float(53) (aka real) is a double-precision (32-bit) floating point number in SQL Server. Regular Float is a single-precision floating point number. Double is a good combination of precision and simplicty for a lot of calculations. You can create a very high precision number with decimal -- up to 136-bit -- but you also have to be careful that you define your precision and scale correctly so that it can contain all your intermediate calculations to the necessary number of digits.

    priyanka.sarkar : You did not specify which is preferable while the case goes for financial transaction and why?
  • Not a complete answer, but a useful link:

    "I frequently do calculations against decimal values. In some cases casting decimal values to float ASAP, prior to any calculations, yields better accuracy. "

    http://sqlblog.com/blogs/alexander_kuznetsov/archive/2008/12/20/for-better-precision-cast-decimals-before-calculations.aspx

Using ASP.NET label as SSRS report parameter

  • I have SSRS report with its own datasets coming straight from the database. I have the report on ASP.NET application page.
  • The application page header has the username and user region details defined in the master page.
  • Now, I want to read this region id label from the ASP.NET page and build my report accordingly. Basically building dataset based on parameters coming from ASP.NET page.
  • Is this possible at all?
From stackoverflow
  • yes, you can send these as parameter to report....

    ReportParameter rpt = new ReportParameter("name", "value");
    

Passing variables from one form to another in QT

I've got two forms, the mainform which opens up a dialog box that has a text box in it. How can I pass the text from the textbox back to the mainform? I've tried alot of different methods but I think I'm missing something simple. Thanks for any help.

From stackoverflow
  • If you use the MVC pattern, you create the model object (container for your data) and pass to the text box to fill in the text value itself. When the dialog is closed, just read the value from the model and put it wherever you need it.

  • The dialog box still exists after it closes. So you can, from the main form, do something like this:

    QString text = subform->textEdit->text();
    

    This assumes your dialog box is subform and the name you gave to the text edit box is textEdit. Make sure you make textEdit public in the designer.

    If you don't want to make textEdit public, then you can add a getter to subform.

    whatWhat : This is basically what I just figured out, I was doing it right..I just "forgot" the proper way to make c++ functions inside classes. I was doing QString getValue() instead of QString MainForm::getValue().

how can i make the google maps bubble longer in height?

i want to be able to put more information into the bubble so maybe making it dynamically longer based on the content that is inserted into it.

thanks

From stackoverflow

Anonymous SMTP Service

Does anyone know of a free, anonymous smtp service? I want to give users of my app the ability to occasionally send me an anon email without having to configure a server of enter their email account. I guess I could setup a gmail account for this purpose and embed the credentials in the app but I hope it won't be necessary. In case it sways your answer, this is a thick client (.NET Console) app.

From stackoverflow
  • If there were such a thing, wouldn't it immediately be swamped by spammers?

  • You might be better off setting up some kind of commenting tool on your website, that sends you an email with the contents of whatever form the user submits. Then if you go that far, it shouldn't be difficult to add a form to your app that automatically makes the full HTTP request (transparent to the user, in the background).

    James Cadd : Thanks - if it were a web site that may be an option, but this is a thick client app.
  • I think that what you're asking for is called an open relay.

  • If you run your own mail server, you can simply configure the app to deliver mail directly to it. Many web hosting companies also provide mail hosting if you don't want to run it on your own hardware. Gmail via Google Apps for your domain might be an option. It's free. But their anti-spam measures might prevent delivery. Better to have a server you can control, I think. Bottom line, though, is you don't need an anonymous SMTP relay server to get the job done.

WriteableBitmap unavailable?

I've discovered what may be the perfect answer to a question on buffered drawing, but for some reason my version of VS2008 doesn't seem to have a WriteableBitmap? I've tried including the relevent namespaces as per the documentation:

using namespace System::Windows::Media;
using namespace System::Windows::Media::Imaging;

But that just gives me errors:

d:\experiments\graphicscontrols\graphicscontrollib\GraphicsControlLibControl.h(9) : error C2039: 'Media' : is not a member of 'System::Windows'
d:\experiments\graphicscontrols\graphicscontrollib\GraphicsControlLibControl.h(10) : error C3083: 'Media': the symbol to the left of a '::' must be a type
d:\experiments\graphicscontrols\graphicscontrollib\GraphicsControlLibControl.h(10) : error C2039: 'Imaging' : is not a member of 'System::Windows'
d:\experiments\graphicscontrols\graphicscontrollib\GraphicsControlLibControl.h(52) : error C2065: 'WriteableBitmap' : undeclared identifier

Do I have an older version of .net installed or something? Is there any way to tell what version visual studio is using? I've updated VS to service pack 1 which made no difference.

From stackoverflow
  • You must target .Net framework 3.0 or 3.5 to get this. Also you will need to add a ref to PresentationCore.dll.

    Jon Cage : Thanks, I was missing two references as it turns out: 'WindowsBase' and 'PresentationCore'

Swiching between Http or Https (based on parent directory)

I have a direcory for the members area.

All the files within that directory should be treated by https.

All other files outside the specific dir should be treated by http.

How can i automate the redirecting from http and https and vice versa?

Btw, the links are relative.

From stackoverflow
  • Best thing I can think of to cover humans would be to rewrite the urls using javascript. If they are all relative then it shouldn't be too tricky.

    I'd note that mixing sites like this have some drawbacks, principally browsers don't like HTTPS pages with insecure HTTP requests involved. A better plan might be to make everything relative and only kick over to https mode once you need to hit the https section.

    I can see a few ways to do this using IIS, but those options really depend on how much you can muck with the IIS configuration and what sorts of resources you have.

  • This sounds like it might best be managed through HTTP server configuration. E.g. mod_rewrite and similar.

    Try asking on http://serverfault.com/

  • You can use the SecureWebPages assembly and web.config entries from Switching Between HTTP and HTTPS Automatically: Version 2. It's a nice piece of kit, I've used it in the past to automatically switch login and admin pages to https

Help with Join

I need help with a join I think. Can't figure it out.

I have these tables:

Posts

`id` int(10) unsigned NOT NULL,
`title` varchar(140) DEFAULT NULL,
`text` text COLLATE utf8_unicode_ci

Posts tags

`post_id` int(10) unsigned NOT NULL,
`tag_id` int(10) unsigned NOT NULL

Tags

`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(40) DEFAULT NULL

If I want to loop out all the posts with the tag team-fortress-2 how would one do that? I can't figure it out.

$q = mysql_query("SELECT * FROM ... WHERE $get['tag']");
while($r = mysql_fetch_array($q)) {
From stackoverflow
  • SELECT p.*
    FROM posts p
    JOIN posttags pt ON pt.post_id = p.id
    JOIN tags t ON pt.tag_id = t.id
    WHERE t.name = 'team-fortress-2'
    

    is the specific example. In PHP you'd do this:

    $tag = mysql_real_escape_string($get['tag']);
    $sql = <<<END
    SELECT p.*
    FROM posts p
    JOIN posttags pt ON pt.post_id = p.id
    JOIN tags t ON pt.tag_id = t.id
    WHERE t.name = '$tag'
    END;
    $query = mysql_query($sql);
    if (!$query) {
      $error = mysql_error();
      die("Error $error for query $sql");
    }
    ...
    

    Escaping the tag is really important, particularly if you are accepting it from user input in any way.

    Guffa : p.post_id should be pt.post_id...
    Lucero : +1 for the warning about escaping the user input (SQL injection prevention)
  • The SQL should look something like this:

    select
       p.id, p.title, p.text
    from
       Posts p
       inner join PostTags pt on pt.post_id = p.id
       inner join Tags t on t.id = pt.tag_id
    where
       t.name = 'team-fortress-2'
    

Parent window and thread affinity

I'm having a WinForms application where I would like to perform some long-running operations, e.g. imagine Explorer copying 2 big files in parallel. For each of those long-running operations I'm starting a separate UI thread (which includes pumping messages/Application.Run/Application.ExitThread) where I create an instance of the IProgressDialog.

I'm wondering - due to the thread affinity of windows - is it legal to package the main form's handle into a HandleRef and pass it as owner/parent of the progress dialog, which is on a different UI thread? I'm not accessing the main window's handle from the secondary UI thread (no cross-thread exceptions in debug mode), only passing it on to the native function.

Thanks.

From stackoverflow
  • Yes, that's fine. Windows allows windows of different threads to have a parent/child relationship.

JQuery ui.core.js

I found the beginning of the code of ui.core.js of JQuery UI quite interesting,

;jQuery.ui || (function($) {
// code...
})(jQuery);

What is the reason to have ';' in the front?

From stackoverflow
  • It is there for concatenation purposes in case one would want to concatenate this file at the end of another script. It effectively fool-proofs concatenation to scripts that have not been terminated properly by a semi-colon.

    So, given the following script:

    alotOfJsCode(argument);
    var fileEnd = noSemiColon
    

    The semi-colon at the beginning allows to prevent this:

    alotOfJsCode(argument);
    var fileEnd = noSemiColonjQuery.ui || (function($) { //...
    

    Which would cause the code to fail.

    In JavaScript, a semi-colon all by itself has no syntactic value. The following two statements are the same:

    //Statement 1
    ;;; ;; ; alert('hello world!'); ;;; ;; ;;
    
    //Statement 2
    alert('hello world!');
    
    musicfreak : Huh, I didn't know that was valid JavaScript. +1

Install a custom ASPX file as part of a ListTemplate definition

I am using VSeWSS 1.3 to create a custom list definition scoped to 'Site'.

    <Elements Id="8924acef-84ef-4584-ade4-e3eaeb8df345" xmlns="http://schemas.microsoft.com/sharepoint/">

  <ListTemplate Name="MyListDefinition"
                DisplayName="MyList"
                Description=""
                BaseType="0"
                Type="10888"
                OnQuickLaunch="TRUE"
                SecurityBits="11"
                Sequence="410"
                Image="/_layouts/images/itgen.gif" />

  <CustomAction
    Id="MyList.Print"
    Location="Microsoft.SharePoint.StandardMenu"
    GroupId="ActionsMenu"
    Title="Print MyItem"
    Description="Print Empty copies of this form."
    RegistrationType="List"
    ControlAssembly="MyList, Version=1.0.0.0, Culture=neutral, PublicKeyToken=de6e0316a726abcd, processorArchitecture=MSIL"
    ControlClass="MyList.PrintActionMenu" />

  <Module Name="ActionPages" Url="">
    <File Url="PrintForm.aspx" Type="Ghostable" Path="MyListDefinition\PrintForm.aspx" />
  </Module>
</Elements>

The file 'PrintForm.aspx' is correctly installed on the server under ...\12\TEMPLATE\Features... , but it doesn't show up under the expected URL http://localhost/site/lists/listname/PrintForm.aspx after installing the list template and creating a new list instance using this template.

I suspect I am missing the correct properties in the and/or tags in my ListDefinition.xml file (shown above).

From stackoverflow
  • You should also have a schema.xml and in the schema.xml there should be something like this:

    <Forms>
      <Form Type="DisplayForm" Url="DispForm.aspx" WebPartZoneID="Main" />
      <Form Type="EditForm" Url="EditForm.aspx" WebPartZoneID="Main" />
      <Form Type="NewForm" Url="NewForm.aspx" WebPartZoneID="Main" />
      ...... your form here
    </Forms>
    

    P.S. try the SharePoint Solution Generator to export an existing List (Comes with VSeWSS), it'll give you a complete xml definition. You can use that as a reference.

    P.P.S. in the link posted in the comment it states that files should be registered in the feature like so:

    <ElementFile Location="GenericList\schema.xml" />
    <ElementFile Location="GenericList\DispForm.aspx" />
    <ElementFile Location="GenericList\EditForm.aspx" /> 
    <ElementFile Location="GenericList\NewForm.aspx" /> 
    <ElementFile Location="GenericList\AllItems.aspx" />
    
    Philipp Schmid : What's the value for the Type attribute?
    Colin : Not sure. add your form to a list and then use SSG to reverse engineer the xml needed. also, SPSource can do the same...
    Colin : also, check this out: http://www.sharepointdevwiki.com/display/public/Creating+a+List+Template+within+a+Feature
  • If it is anywhere, I would expect PrintForm.aspx to show up in the root folder of your website when the Url of your Module element is blank. Try this:

      <Module Name="ActionPages" Url="lists/listname">    
            <File Url="PrintForm.aspx" Type="GhostableInLibrary" Path="MyListDefinition\PrintForm.aspx" />  
      </Module>
    

    Also, try GhostableInLibrary instead of Ghostable as the File Type.

    Finally, you mention that PrintForm.aspx does show up somewhere in Features, but did not give the complete path. Make sure it is in ...\12\TEMPLATE\Features\YourFeaturesName\MyListDefinition\PrintForm.aspx. Based on the value of the Path attribute, PrintForm.aspx needs to be in a directory named MyListDefinition within your Feature.

jquery ajax parse response text

Ok this is really frusturating me because I've done this a hundred times before, and this time it isn't working. So I know I'm doing something wrong, I just can't figure it out.

I am using the jQuery .get routine to load html from another file. I don't want to use .load() because it always replaces the children of the element I'm loading content into.

Here is my .get request:

$(document).ready(function() {
    $.get('info.html', {}, function(html) {
        // debug code
        console.log($(html).find('ul').html());
        // end debug code
    });
});

The file 'info.html' is a standard xhtml file with a proper doctype, and the only thing in the body is a series of ul's that I need to access. For some reason, the find function is giving me a null value.

In firebug, the GET request is showing the proper RESPONSE text and when I run

console.log(html);

Instead of the current console.log line, I get the whole info.html as output, like I would expect.

Any ideas?

From stackoverflow
  • You cannot pull in an entire XHTML document. You can only handle tags that exist within the <body> of an html document. Frustrating. Strip everything from info.html that isn't within your <body> tag and try it again.

    There are other potential ways around this issue - check below "Stackoverflow Related Items" at the base of this response.

    From the Doc: (http://docs.jquery.com/Core/jQuery#htmlownerDocument)

    "HTML string cannot contain elements that are invalid within a div, such as html, head, body, or title elements."

    Stackoverflow Related Items:

    W_P : So I need to write a php script to sit inbetween the 2 html files and have the get request go there, huh....that is frusturating, i was hoping to avoid that.
    Jonathan Sampson : I believe so, yes. In all honesty, you could use phpQuery within your PHP Script. it will allow you jQuery style selectors making it easy to return the contents.
    W_P : stripping out everything but what's within the doesn't work either...i get the correct response but can't parse it...thanks anyway!
    Jonathan Sampson : Your document is well-formed, right? Nothing like etc in it?
    W_P : no, it's just html->body->ul->li. body has a few ul->li sets under it but it's all valid. I decided i am just going to use .load() into a hidden div, parse the data, and prepend the parsed data to where i want it to be
    Jonathan Sampson : Before you do that, check out my answer - I've found a couple resources for you that might help.
    Richard M : I can't see anything wrong with your code. But, if you have more than one UL in the returned html then ".find('ul').html()" is only going to give you the html for the first of those elements.
    Jonathan Sampson : Triffid, are you sure about that? I was thinking it might return all of the LI's from any of the UL elements.
  • Try including whole body within a <div> tag, e.g. <body><div>content</div></body>.

Is it possible to use a 32-bit ODBC driver with a 64-bit application on windows?

I have a 64-bit application and an ODBC-driver which only comes in 32-bit-flavour. Is there any way to have the application connect to the datasource through the driver?

I realize the short answer is NO, related to 64-bit applications not being able to load a 32-bit dll, but I am looking for a slightly longer and more positive answer.

Re-writing the driver is not an option at this point.

From stackoverflow
  • Host the ODBC-driver in a 32-bit process, and communicate between your now 64-bit application and the process. Pick your IPC of choice for doing so (I'd probably go with sockets, for no particular reason).

    Here's an article that discusses this approach, and some of the implications.

Problem with jquery handling checkboxes in IE8

I am using jquery to locate all the checkboxes in a table column that are checked. For that purpose I am using the following code:

        $("input[type=checkbox][checked]").each(function() {

             //Do Stuff

        });

This works fine in Firefox 3 but does not work in IE8 or Safari. Can anyone explain why and/or provide a workaround?

EDIT: I'm using jQuery v1.3.2

From stackoverflow
  • try $("input[type=checkbox]:checked").each...

    Edit or even sweeter: $("input:checkbox:checked").each...

    That works for me in IE8.

    Paolo Bergantino : Fixed your answer, :checkbox alone is not recommended...
    peirix : thank you, good sir (:
  • Try this

     $("input:checked").click(function(){
       alert('abc');    
          }) ;
    
  • A workaround:

    $("input:checked").each(function() {
        //Do Stuff
    });
    
    peirix : this would hit radio buttons as well, though...

getting row count in db2 using system tables ?

howdy!

I can get row count from system table in db2 using

select tabname,card from syscat.tables where tabname='?'

but this will give static row count,If I need to get dynamic one I need to run runstats on the table. is there any other way apart from using count(*) ?

Cheers, Prateek

From stackoverflow

How do I get revolving last 12 months in T-SQL 2005?

At the moment I use DATEPART(yy, MY_DATE) = DATEPART(yy, GETDATE()) to get Year-To-Date details and have to convert it into the revolving last 12 months. How would I do that?

From stackoverflow
  • You can do date arithmetic with dateadd, e.g. where MY_DATE > dateadd (yy, -1, getdate())

    Garry Shutler : This is exactly what I was going to put.
    Greg : Thanx a million!

Markdown.NET incorrectly does not escape HTML-Tags

Hi, it seems that Markdown.NET does not escape the following:

<script>

which is kind of a problem...

Is there any other way of generating HTML from Markdown on the server with ASP.NET?

From stackoverflow

Time only pickers for .NET WinForms?

There are tons of good date pickers out there for Windows forms, but I have yet to find any good time only pickers.

Any suggestions?


EDIT

I guess I should be more clear. I am talking about a nicer looking time picker. We use a commercial control suite, and the default time picker looks out of place because it is so plain.

From stackoverflow
  • You mean, as opposed to the standard Winforms DateTimePicker?

    this.dateTimePicker1.CustomFormat = "hh:mm";
    this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
    

    ...

    private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
    {
        MessageBox.Show(dateTimePicker1.Value.TimeOfDay.ToString());
    }
    
  • DatePicker has a property Format that can be set to Time. Be sure to set ShowUpDown to True.

    Infragistics is pretty popular for Winforms and has the option for its DateTimePicker.

    ... setting the MaskInput to {time} should get the behavior you are looking for. If you only set the FormatString property, the the time will display only when the control is in edit mode (when the cursor is in the control).

    from http://forums.infragistics.com/forums/t/4172.aspx

set the height of freetextbox

How should I go about setting the height of freetextbox? I want to size the textbox reasonably based on the lenght of the text in the textbox.

From stackoverflow
  • simply set the height property of textbox as much you want... like..

    <FTB:FreeTextBox ID="txtDesc" runat="server" Width="590px" Height="300px" ></FTB:FreeTextBox>
    

Dealing with gridview in asp.net

When I added 'edit' column to gridview,I got this problem:

The GridView 'RegisteredList' fired event RowEditing which wasn't handled.

How I will fix it? and Thank you very much..

From stackoverflow
  • You need to handle the event RowEditing. In the markup:

    <asp:GridView id="RegisteredList" runat="Server" 
    OnRowEditing="RegisteredList_RowEditing"/>
    

    And in the code behind:

    protected void RegisteredList_RowEditing(object sender, GridViewEditEventArgs e)
    {
        //do stuff
    }
    

iPhone 3.0 Compass: how to get a heading?

I'm relatively new to Objective-C and really don't know much about it yet, so I apologise for what is probably a really amateurish question.

I'm trying to get the magnetic heading from CLHeading and CLLocationDirection. However I'm getting compile errors for this line of code:

locationLabel.text = [[[location course] magneticHeading] stringValue];

The errors are:
warning: invalid receiver type 'CLLocationDirection'
error: cannot convert to a pointer type

I don't really understand what I'm doing wrong here. Please help!

From stackoverflow
  • How are you allocating and initializing location? Make sure location is defined as a (CLLocationDirection *) and not just a (CLLocationDirection).

  • Here are the steps needed to use the compass.

    1) check the availability: if the headingAvailable property of the location manager is YES, then you can use the compass.

    2) use the location manager method -(void) startUpdatingHeading to begin receiving the information you are searching for

    3) actually retrieve this information using the delegate method (do not forget to set yourself as the delegate)

     - (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
    

    Hope this helps.

  • magneticHeading is of CLLocationDirection type, which is simply a typedef for the primitive data type "double". In your example you are trying to send a message to something that is not an object ! You should simply format the double like so:

    locationLabel.text = [NSString stringWithFormat:@"Heading %.3f", [[location course] magneticHeading]];

    Sean R : Thanks, this was where I was getting really confused. I need to learn more about typedefs I guess.
  • Hi,

    Can you help me. Do you have semple about compass?

    Im begim in C and iPhone.

    Thanks..

    Raul

    Marcelo Cantos : This isn't an answer.

ASP.NET Application and ASPNETDB.MDF

I've built an ASP.NET application and noticed that my /App_Data folder contains two files: ASPNETDB.MDF and aspnet_log.mdf. They total about 10MB in size.

I'm handling security via an Oracle database and authentication mode = "Forms".

Why did these files get created? Is it safe to delete them?

From stackoverflow
  • I'm guessing before you configured the providers you clicked on the manage asp.net application button which may have created these for you.

    tmcallaghan : If that is the case are they safe to delete?
    awe : Yes it is safe to delete it. I did, and nothing bad happened. All settings for your app is stored in `web.config`.

How do I extract data from a FoxPro memo field using .NET?

Hi,

I'm writing a C# program to get FoxPro database into datatable everything works except the memo field is blank or some strange character. I'm using C# .Net 2.0. I tried the code posted by Jonathan Demarks dated Jan 12. I am able to get the index but i don't know how to use this index to fetch the data from memo file.

Pleaese help me.

Thanks Madhu

From stackoverflow
  • Have you tried using the FoxPro OLEDB provider? If the database doesn't use features introduced by VFP8 or 9 (notably database events) you could use the ODBC driver as well.

    Are these general fields containing documents or images, or text memos or binary memos? What code are you using to extract the data?

    Madhu kiran : Hi Stuart,thanQ Binary Memos. OleDbConnection Conn = new OleDbConnection(@"Provider=VFPOLEDB.1;Data Source=C:\Documents and Settings\All Users\Documents\LSP\LEVEL2.dbf"); Conn.Open(); Oledbadapter da = new OleDbDataAdapter("Select * From LEVEL2",Conn); da.fill(ds); and i am trying to read each field
  • I created a function that converts the object returned by the selection to an array of bytes

    private byte[] ObjectToByteArray(Object obj) { if (obj == null) return null; BinaryFormatter bf = new BinaryFormatter(); MemoryStream ms = new MemoryStream(); bf.Serialize(ms, obj); return ms.ToArray(); }

    then you display the value

    byte [] dBytes = ConvertObjectToByteArray(dr["profile"]); string str; System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); str = enc.GetString(dBytes);

    you can now do whatever you want to do with your str

Simple mod_rewrite problem

I am new to using mod_rewrite and am trying to rewrite pages at the base level of my site:

www.site.com

I want to rewrite any of the following URLs www.site.com/main www.site.com/settings www.site.com/username

To: www.site.com/index.php?v=main www.site.com/index.php?v=settings www.site.com/index.php?v=username

I had this working when I had mod_rewrite set up under www.site.com/directory/ but can't figure out how to make it work with www.site.com

RewriteEngine On
RewriteRule ^/([^/\.]+)/?$ index.php?v=$1 [L]
From stackoverflow
  • You have an extra "/" there. That should be:

    RewriteEngine On
    RewriteRule ^([^/\.]+)/?$ index.php?v=$1 [L]
    
    Gumbo : You don’t have to escape the dot inside a character class declaration.
  • The correct rule would be...

    RewriteRule ^([^/\.]+)/?$ index.php?v=$1 [L,NC,QSA]
    

    But you might hit some problems - for example if you have REAL directories - this will rewrite them too and prevent you from using them. You have two options to avoid the problem, you can write many rules, like this:

    RewriteRule ^Directory/?$ index.php?v=directory [L,NC,QSA]
    

    Or you can use a "pretend directory" like this...

    RewriteRule ^Content/([^/\.]+)/?$ index.php?v=$1 [L,NC,QSA]
    

    In the second example, your URL would be www.site.com/Content/Directory/

    I've put NC and QSA on my attributes - No Case and Query String Append. You should definitely use NC, and QSA is useful in some implementations.

  • I would settle on whether the path should be /settings or /settings/ (you currently match both) and so on (personally, I prefer /settings.) I believe that it's a good idea to make paths as non-ambigous as possible. If you were to match paths like /settings, you would do like this:

    RewriteEngine On
    RewriteRule ^(\w+)$ index.php?v=$1 [L]
    

    Also have a look at the QSA flag if you want to support additional query parameters (for example: /settings?tab=password to index.php?v=settings&tab=password.) I'm mentioning it because that's something that bothered me in the beginning.

How to update assmebly version info with new build and revision during build?

I have to update the build number in assembly version of assemblyinfo.cs file. I have written a custom tasks which updates all the assmeblyinfo.cs under a solution before starting build. But when i change this file and try to build then some of my dlls which has reference of other dlls not able to compile as they dont find the specific version assembly. I have some files which uses strong name assembly also. Not sure how to update their version. I have tried setting specific version to false,but still same error is coming.

Can you anybody tell me the good way to update the assemblyinfo.cs with incremental build number?

P.S. i am using NANT tasks for automating by builds.

From stackoverflow

Php safe output

Hola

When outputting user input I use this function:

function bbkoda($text) {
$text = htmlspecialchars($text);
$text = nl2br($text);


$hitta = array(
          "'\[b](.*?)\[/b]'is",
          "'\[i](.*?)\[/i]'is"
          );

$byt = array(
             "<b>\\1</b>",
             "<i>\\1</i>"
            );

$text = preg_replace($hitta, $byt, $text);

return $text;
}

This is pretty safe right? I sanitize all i insert to db with mysql_real_escape_string and output it with htmlspecialchars. Im a very doubtful person :P

Thanks

From stackoverflow
  • There is already a quite good explanation on stackoverflow on this topic. Basically you definitely need to work on your in- and output to get it really safe!