Daily Archives

Articles indexed Wednesday May 19 2010

Page 25/122 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • Rails: Pass association object to the View

    - by Fedyashev Nikita
    Model Item belongs_to User. In my controller I have code like this: @items = Item.find(:all) I need to have a corresponding User models for each item in my View templates. it works in controller(but not in View template): @items.each { |item| item.user } But manual looping just to build associations for View template kinda smells. How can I do this not in a creepy way?

    Read the article

  • LevelToVisibilityConverter in silverligt 4

    - by prince23
    <UserControl x:Class="SLGridImage.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"> <UserControl.Resources> <local:LevelToVisibilityConverter x:Key="LevelToVisibility" /> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White"> <sdk:DataGrid x:Name="dgMarks" CanUserResizeColumns="False" SelectionMode="Single" AutoGenerateColumns="False" VerticalAlignment="Top" ItemsSource="{Binding MarkCollection}" IsReadOnly="True" Margin="13,44,0,0" RowDetailsVisibilityMode="Collapsed" Height="391" HorizontalAlignment="Left" Width="965" VerticalScrollBarVisibility="Visible" > <sdk:DataGrid.Columns> <sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button x:Name="myButton" Click="myButton_Click"> <StackPanel Orientation="Horizontal"> <Image Margin="2, 2, 2, 2" x:Name="imgMarks" Stretch="Fill" Width="12" Height="12" Source="Images/test.png" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{Binding Level, Converter={StaticResource LevelToVisibility}}" /> <TextBlock Text="{Binding Level}" TextWrapping="NoWrap" ></TextBlock> </StackPanel> </Button> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn Header="Name" > <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate > <Border> <TextBlock Text="{Binding Name}" /> </Border> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn Header="Marks" Width="80"> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Border> <TextBlock Text="{Binding Marks}" /> </Border> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> </sdk:DataGrid.Columns> </sdk:DataGrid> </Grid> </UserControl> in .cs using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.Collections.ObjectModel; using System.ComponentModel; namespace SLGridImage { public partial class MainPage : UserControl { private MarksViewModel model = new MarksViewModel(); public MainPage() { InitializeComponent(); this.DataContext = model; } private void myButton_Click(object sender, RoutedEventArgs e) { } } public class MarksViewModel : INotifyPropertyChanged { public MarksViewModel() { markCollection.Add(new Mark() { Name = "ABC", Marks = 23, Level = 0 }); markCollection.Add(new Mark() { Name = "XYZ", Marks = 67, Level = 1 }); markCollection.Add(new Mark() { Name = "YU", Marks = 56, Level = 0 }); markCollection.Add(new Mark() { Name = "AAA", Marks = 89, Level = 1 }); } private ObservableCollection<Mark> markCollection = new ObservableCollection<Mark>(); public ObservableCollection<Mark> MarkCollection { get { return this.markCollection; } set { this.markCollection = value; OnPropertyChanged("MarkCollection"); } } public event PropertyChangedEventHandler PropertyChanged; public void OnPropertyChanged(string propName) { if (PropertyChanged != null) this.PropertyChanged(this, new PropertyChangedEventArgs(propName)); } } public class Mark { public string Name { get; set; } public int Marks { get; set; } public int Level { get; set; } } public class LevelToVisibilityConverter : System.Windows.Data.IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { Visibility isVisible = Visibility.Collapsed; if ((value == null)) return isVisible; int condition = (int)value; isVisible = condition == 1 ? Visibility.Visible : Visibility.Collapsed; return isVisible; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } #endregion } } when i run getting error The type 'local:LevelToVisibilityConverter' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. what i am i missing here looking forward for an solution thank you

    Read the article

  • SQL Server Bulk insert of CSV file with inconsistent quotes

    - by mattstuehler
    Is it possible to BULK INSERT (SQL Server) a CSV file in which the fields are only OCCASSIONALLY surrounded by quotes? Specifically, quotes only surround those fields that contain a ",". In other words, I have data that looks like this (the first row contain headers): id, company, rep, employees 729216,INGRAM MICRO INC.,"Stuart, Becky",523 729235,"GREAT PLAINS ENERGY, INC.","Nelson, Beena",114 721177,GEORGE WESTON BAKERIES INC,"Hogan, Meg",253 Because the quotes aren't consistent, I can't use '","' as a delimiter, and I don't know how to create a format file that accounts for this. I tried using ',' as a delimter and loading it into a temporary table where every column is a varchar, then using some kludgy processing to strip out the quotes, but that doesn't work either, because the fields that contain ',' are split into multiple columns. Unfortunately, I don't have the ability to manipulate the CSV file beforehand. Is this hopeless? Many thanks in advance for any advice. By the way, i saw this post SQL bulk import from csv, but in that case, EVERY field was consistently wrapped in quotes. So, in that case, he could use ',' as a delimiter, then strip out the quotes afterwards.

    Read the article

  • microsoft certification in c# 3.5 and its tutorials

    - by user238284
    i am 2010 passed out. i am interested in completing a certification in c#. certifications available are MCTS Exam 70 536 (for framework 3.5 / 2) and MCTS Exam 70 515(for framework 4.0). wer wil i get its proper study material and tutorials. is there any recommendation from u about, from which exam a beginner in c# should start with.. please help me ....... **thanking u** http://www.microsoft.com/learning/en/us/certification/cert-vstudio.aspx#tab2 http://en.csharp-online.net/CSharp_Certification%2C_Development%2C_and_Training

    Read the article

  • How do I do Textbox Submit

    - by Newb
    Hello everyone, I have a search box and a buttion. currently a user enter some text and press the search button. But I want to add another feature that instead of clicking the search button people can hit enter to search. How can I do that? Here is my code sample: <form method="post" action=""> <input id="search" name="search" type="text" /> <input id="search_btn" name="search_btn" type="submit" /> </form> Thanks in advance

    Read the article

  • UUID Cassandra.

    - by Sandeep
    Hi all, I am new to Cassandra. I am trying to insert some values to the columnfamily. The definition of columnfamily in the config file is as follows. <ColumnFamily Name="CommandQueue" ColumnType="Super" CompareWith="TimeUUIDType" CompareSubcolumnsWith="UTF8Type"/> When ever I try to insert values to I always get "InvalidRequestException(why: UUIDs must be exactly 16 bytes)". I am using batch_mutate() to insert column. How can I insert values to the column family.

    Read the article

  • comparing salt and hashed passwords during login doesn't seem work right....

    - by Pandiya Chendur
    I stored salt and hash values of password during user registration... But during their login i then salt and hash the password given by the user, what happens is a new salt and a new hash is generated.... string password = collection["Password"]; reg.PasswordSalt = CreateSalt(6); reg.PasswordHash = CreatePasswordHash(password, reg.PasswordSalt); These statements are in both registration and login.... salt and hash during registration was eVSJE84W and 18DE22FED8C378DB7716B0E4B6C0BA54167315A2 During login it was 4YDIeARH and 12E3C1F4F4CFE04EA973D7C65A09A78E2D80AAC7..... Any suggestion.... public static string CreateSalt(int size) { //Generate a cryptographic random number. RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); byte[] buff = new byte[size]; rng.GetBytes(buff); // Return a Base64 string representation of the random number. return Convert.ToBase64String(buff); } public static string CreatePasswordHash(string pwd, string salt) { string saltAndPwd = String.Concat(pwd, salt); string hashedPwd = FormsAuthentication.HashPasswordForStoringInConfigFile( saltAndPwd, "sha1"); return hashedPwd; }

    Read the article

  • Stored procedure using cursor in mySql.

    - by RAVI
    I wrote a stored procedure using cursor in mysql but that procedure is taking 10 second to fetch the result while that result set have only 450 records so, I want to know that why that proedure is taking that much time to fetch tha record. procedure as below: DELIMITER // DROP PROCEDURE IF EXISTS curdemo123// CREATE PROCEDURE curdemo123(IN Branchcode int,IN vYear int,IN vMonth int) BEGIN DECLARE EndOfData,tempamount INT DEFAULT 0; DECLARE tempagent_code,tempplantype,tempsaledate CHAR(12); DECLARE tempspot_rate DOUBLE; DECLARE var1,totalrow INT DEFAULT 1; DECLARE cur1 CURSOR FOR select SQL_CALC_FOUND_ROWS ad.agentCode,ad.planType,ad.amount,ad.date from adplan_detailstbl ad where ad.branchCode=Branchcode and (ad.date between '2009-12-1' and '2009-12-31')order by ad.NUM_ID asc; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET EndOfData = 1; DROP TEMPORARY TABLE IF EXISTS temptable; CREATE TEMPORARY TABLE temptable (agent_code varchar(15), plan_type char(12),sale double,spot_rate double default '0.0', dATE DATE); OPEN cur1; SET totalrow=FOUND_ROWS(); while var1 <= totalrow DO fetch cur1 into tempagent_code,tempplantype,tempamount,tempsaledate; IF((tempplantype='Unit Plan' OR tempplantype='MIP') OR tempplantype='STUP') then select spotRate into tempspot_rate from spot_amount where ((monthCode=vMonth and year=vYear) and ((agentCode=tempagent_code and branchCode=Branchcode) and (planType=tempplantype))); INSERT INTO temptable VALUES(tempagent_code,tempplantype,tempamount,tempspot_rate,tempsaledate); else INSERT INTO temptable(agent_code,plan_type,sale,dATE) VALUES(tempagent_code,tempplantype,tempamount,tempsaledate); END IF; SET var1=var1+1; END WHILE; CLOSE cur1; select * from temptable; DROP TABLE temptable; END // DELIMITER ;

    Read the article

  • new user registration on ejabberd server using jaber.net

    - by SR Dusad
    Hi I m working on an online text chat program in C#.Net . For this i m using ejabberd server and for build a client m using jaber.net .But i m facing some problem during the new user registration . Can anyone give me a proper code for register new user or some advise or instruction to create new account. Any type of help will be appreciated. Thanks in advance

    Read the article

  • Again, what version control system to choose?

    - by Ivan
    Please excuse me for probably a newbie hundred-times-chewed question. I have no experience with version control systems except of using Visual Source Safe in a project done by 2 people sitting in front of each other (which has shown VSS quite sack of boulders, not anything useful). Right now I am looking to grok-in using some modern VCS. Here are the preferences in descending priority order: Platform-agnostic. Pretty pleasant to use With Visual Studio 2010 on Windows as well as With NetBeans 6.9 and Eclipse 3.6 on Linux and Mac. Convenient and efficient for mutually-dependent projects done by teams of 1-10 and consisting of files of quite a diverse selection of types. Including early-stage projects with unstable design and experimenting. Modern. As fresh and future-technology-feature-rich as possible. Free & open-source. Should I take a closer look at SVN, Mercurial, GIT, Bazaar, or something else?

    Read the article

  • java tracing spaghetti code

    - by Amarsh
    Folks, I have just joined this company which has a huge source tree based upon JSP/Servlet and EJB 1.2. No documentation exists. The code has been written over seven years, with a large number of undocumented changes. Are there any tool tah can assist me in tracing the execution? Putting a breakpoint is not helping me much.

    Read the article

  • C++ : Declaring the array size with a non-constant variable

    - by Jérôme
    I always thought that when declaring an array in C++, the size has to be a constant integer value. For instance : int MyArray[5]; // correct or const int ARRAY_SIZE = 6; int MyArray[ARRAY_SIZE]; // correct but int ArraySize = 5; int MyArray[ArraySize]; // incorrect Here is also what is explained in The C++ Programming Language, by Bjarne Stroustrup : The number of elements of the array, the array bound, must be a constant expression (§C.5). If you need variable bounds, use a vector(§3.7.1, §16.3). For example: void f(int i) { int v1[i]; // error : array size not a constant expression vector<int> v2[i]; // ok } But to my big surprise, the code above does compile fine on my system ! Here is what I tried to compile : void f(int i) { int v2[i]; } int main() { int i = 3; int v1[i]; f(5); } I got no error ! I'm using GCC v4.4.0. Is there something I'm missing ?

    Read the article

  • jQuery number seperator - Seperate number by each 1.000

    - by Kim Andersen
    Hi I'm developing a new site, and in here it's possible for the user to type in a price in a input-textfield. So what I need is some jQuery-code to transforn the typed in price. This means, that when a user types in "1000", the vissible text in the input field shall automatically be transformed to "1.000" - with a period. And if they type in "10000" it should be transformed to "10.000" etc. You can see a live example on this website I found: http://www.boligsiden.dk/ I know it's on danish, but on the frontpage under the map, there are to input fields. One of them is saying "Minimum kontaktpris". You can try to type in a number in here, and see the effect that I'm looking for. Does anybody know how I can achieve this? Either by a jQuery plugin, or by some "homemade"-code? Thanks in advance. /Kim Andersen

    Read the article

  • Display On-Screen Television Graphics During Live Broadcasts

    - by ServAce85
    How and with what software do major television companies display on-screen graphics during their programs? For example: On ESPN, how do they produce the news ticker on the bottom (both graphically and from a source code point of view), create and display the scores of sports, and update and show selected stats on the fly? I've looked everywhere I can think of to find the answer, but I am at a loss. That's where you guys (and girls) come in. I hope you can help shed some light on this subject for me. Thanks in advance.

    Read the article

  • How to change HEX value to EBCDIC char

    - by vininet
    What is the simplest way to convert HEX value to ebcdic char type in Java e.g. The example below will return at sign but I would like to get ebcidic equivalent i.e. space char.. String hex = "40"; char c = (char) Integer.parseInt(hex, 16);

    Read the article

  • Squid ban policy

    - by VOX
    I need a requirement to let users view a particular website for an hour and then put it into ban list of that user. My company have a team of website reviewers who review their website. In most cases, when they found a good website (online RPG? social sites? web proxies) they enjoy it all the day without ever going to another sites. So I want to let them view a new website for an hour then I want to ban those websites. Is there any convenient way to do it?

    Read the article

  • javascript Programmically exit fullsreen

    - by Mark
    I understand why browsers would disallow websites from programically making the browser fullscreen. However, users typically expect the 'esc' button to exit from full screen, and browsers simply don't do that. Is there any way to get the browser to exit from full screen. Thanks.

    Read the article

  • HTML relative links with URL Rewrite

    - by Adam Kiss
    I have quickie: When you code/develop themes, how do you link to various files in your html/css code? Example: We at our firm use mostly <base target="http://whatever"> in our main template and then just <img src="./images/file.png"> in our html, "/category/page" as links and something alike in our css. However, when testing on different machines, we use ip address rather than localhost on main dev station of coder, so all base links don't work (because localhost goes to viewing machine, not coder's, in our network). Same thing happens when updating pages - on dev server, we have to edit base target, so browsing site won't take us to live site - this part is actually rather simple PHP (if ... echo else echo something else), but it still not solve problem of more coding-testing problems. So, my question is, how do YOU solve it? How do you use relative links, which basically don't care for what domain is the page on and don't care for url rewrite? (because ../images/ is different for / and different for /something/somethingElse/page)?

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >