Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
I have installed silverlight 3 and uses following code:

XML
<UserControl xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" x:Class="SilverlightDB.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">

    <Border BorderBrush="Black" BorderThickness="1">

        <Grid x:Name="LayoutRoot" Background="white"  ShowGridLines="False">

            <Grid.RowDefinitions>
                <RowDefinition Height="35"></RowDefinition>
                <RowDefinition Height="30"></RowDefinition>
                <RowDefinition Height="30"></RowDefinition>
                <RowDefinition Height="30"></RowDefinition>
                <RowDefinition Height="30"></RowDefinition>
                <RowDefinition Height="30"></RowDefinition>
                <RowDefinition Height="40"></RowDefinition>
                <RowDefinition Height="70"></RowDefinition>
            </Grid.RowDefinitions>

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="130"></ColumnDefinition>
                <ColumnDefinition Width="270"></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Width="400" Background="Gray" >

                <controls:Label  FontSize="14"   HorizontalAlignment="Center"  Content="RegistrationForm"  Margin="6,5,-5,5"></controls:Label>

            </StackPanel>

            <controls:Label Grid.Row="1" Grid.Column="0" Content="FirstName" Margin="10,5,5,5" HorizontalAlignment="Center"></controls:Label>

            <TextBox Grid.Column="1" Grid.Row="1" Height="25" Width="150" HorizontalAlignment="Left"></TextBox>

            <controls:Label Grid.Row="2" Grid.Column="0" Content="EmailID" Margin="10,5,5,5" HorizontalAlignment="Center"></controls:Label>

            <TextBox Grid.Row="2" Grid.Column="1" Height="25" Width="150" HorizontalAlignment="Left"></TextBox>

            <controls:Label Grid.Row="3" Grid.Column="0" Content="PhoneNo" Margin="10,5,5,5" HorizontalAlignment="Center"></controls:Label>

            <TextBox Grid.Row="3" Grid.Column="1" Height="25" Width="150" HorizontalAlignment="Left"></TextBox>

            <controls:Label Grid.Row="4" Grid.Column="0" Content="LoginName" Margin="10,5,5,5" HorizontalAlignment="Center"></controls:Label>

            <TextBox Grid.Row="4" Grid.Column="1" Height="25" Width="150" HorizontalAlignment="Left"></TextBox>

            <controls:Label Grid.Row="5" Grid.Column="0" Content="Password" Margin="10,5,5,5" HorizontalAlignment="Center"></controls:Label>

            <TextBox Grid.Row="5" Grid.Column="1" Height="25" Width="150" HorizontalAlignment="Left"></TextBox>

            <Button Grid.Row="6" Grid.Column="1" Width="100" Height="25" HorizontalAlignment="Left" Content="Register" Click="SubmitRegister_Click"></Button>

        </Grid>

    </Border>

</UserControl>


but it gives me an error like

Error   28  Expected '>'.   
Error   30  'Center' is an unexpected token causing the XML to be invalid. White space is expected.
Error   34  Expected '>'.
Error   41  Character sequence '1' was not expected at this location.   


and other error like these
Posted
Updated 14-Aug-10 23:54pm
v3
Comments
Kunal Chowdhury «IN» 15-Aug-10 0:03am    
Reason for Edit: Properly format the code in the query for making it readable.
Dalek Dave 15-Aug-10 5:54am    
Minor Edit for spelling.

Hi eru,

The initializecomponent issue occur when either your namespace is wrong or partial class name is wrong. Here in your code, the XAML is pointing to "SilverlightDB.Page" where "SilverlightDB" is the namespace and the class it is pointing to is "Page". The code behind file it is using "MainPage". Hence it is unable to find the actual code behind to load the components.

Rename the entry in the XAML to point to "SilverlightDB.MainPage" and save the file. It will definitely work. Let me know.

[Please "Vote" and Mark As "Accept Answer" to the post that helps you]
 
Share this answer
 
erummirza wrote:
"xml">

First of all, your xaml is incorrect. Remove this "xml" from your xaml.

Next, are you looking for a sample on how to insert data into a database?
Search on the internet for some samples.
 
Share this answer
 
v2
Sorry, xml word was added by mistake secondly , i ahave removed most of the error now, Actually i foind code in silverlight 2 ,i m using silverlight 3 ,now i need to conver the code in silverlight 3 as i m getting these kinds of error
MSIL
Error   1   The name 'InitializeComponent' does not exist in the current context   

and its not accepting textboxs etc etc.
 
Share this answer
 
You have paster this code in your xaml.
But have you changed the name and namespace of your class file (the code behind file) to the same name i.e. SilverlightDB.Page?
 
Share this answer
 
here is code behind

C#
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 SilverlightDB.ServiceReference1;

namespace SilverlightDB
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
          //  InitializeComponent();
        }
        private void SubmitRegister_Click(object sender, RoutedEventArgs e)
        {

            RegisterClient webservice = new RegisterClient();

            //txtFirstName
            webservice.InsertDataAsync(txtFirstName.Text, txtEmailID.Text, txtPhoneno.Text, txtLoginName.Text, txtPassword.Text);

        }

    }
}
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900