Display XML with XPath - asp.net

I just started using XML, and i have a form where the user adds some information, and is saved into an XML, this is the code to do it, it working fine:
<%# Page Language="C#" AutoEventWireup="true"CodeBehind="DatosFinancieros.aspx.cs"
Inherits="Tablero.DatosFinancieros" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%# Import Namespace="System.Xml" %>
<script runat="server">
protected void btnSave_Click(object sender, EventArgs e)
{
string xmlPath = MapPath("Datos/DatosFinancieros.xml");
XmlDocument doc = new XmlDocument();
//Check if the file already exists or not
if (System.IO.File.Exists(xmlPath))
{
doc.Load(xmlPath);
XmlNode DatosNodo = CreateDatosNodo(doc);
//Get reference to the Datos node and append the Datos node to it
XmlNode DatosFinancierosNodo = doc.SelectSingleNode("DatosFinancieros");
DatosFinancierosNodo.AppendChild(DatosNodo);
lblResult.Text = "El documento ha sido actualizado";
}
else
{
XmlNode declarationNode = doc.CreateXmlDeclaration("1.0", "", "");
doc.AppendChild(declarationNode);
XmlNode comment = doc.CreateComment("Este archivo representa un fragmento de lo almacenado");
doc.AppendChild(comment);
XmlNode DatosFinancierosNodo = doc.CreateElement("DatosFinancieros");
XmlNode DatosNodo = CreateDatosNodo(doc);
//Append the datos node to the DatosFinancieros node
DatosFinancierosNodo.AppendChild(DatosNodo);
//Append the DatosFinancieros node to the document
doc.AppendChild(DatosFinancierosNodo);
lblResult.Text = "El documento ha sido creado";
}
doc.Save(xmlPath);
}
XmlNode CreateDatosNodo(XmlDocument doc)
{
XmlNode datosNodo = doc.CreateElement("Datos");
// Add Neta Mensual attribute to the Datos Node
XmlAttribute NetaMensualAttribute = doc.CreateAttribute("NetaMensual");
NetaMensualAttribute.Value = txtNetaMensual.Text;
datosNodo.Attributes.Append(NetaMensualAttribute);
XmlAttribute NetaAcumuladoAttribute = doc.CreateAttribute("NetaAcumulado");
NetaAcumuladoAttribute.Value = txtNetaAcumulado.Text;
datosNodo.Attributes.Append(NetaAcumuladoAttribute);
XmlAttribute MensualAttribute = doc.CreateAttribute("Mensual");
MensualAttribute.Value = txtMensual.Text;
datosNodo.Attributes.Append(MensualAttribute);
XmlAttribute AcumuladoAttribute = doc.CreateAttribute("Acumulado");
AcumuladoAttribute.Value = txtAcumulado.Text;
datosNodo.Attributes.Append(AcumuladoAttribute);
XmlAttribute LiquidezAttribute = doc.CreateAttribute("Liquidez");
LiquidezAttribute.Value = txtLiquidez.Text;
datosNodo.Attributes.Append(LiquidezAttribute);
XmlAttribute AccionMensualAttribute = doc.CreateAttribute("AccionMensual");
AccionMensualAttribute.Value = TextAccionMensual.Text;
datosNodo.Attributes.Append(AccionMensualAttribute);
XmlAttribute AccionAcumuladaAttribute = doc.CreateAttribute("AccionAcumulada");
AccionAcumuladaAttribute.Value = TextAccionAcumulada.Text;
datosNodo.Attributes.Append(AccionAcumuladaAttribute);
return datosNodo;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td colspan="2" style="width: 200px; height: 40px">
<b style="font-size: x-large">Datos Financieros</b>
</td>
</tr>
<tr>
<td colspan="2" style="width: 174px; height: 40px">
<b>Utilidad Neta/Capital</b>
</td>
</tr>
<tr>
<td style="width: 101px; height: 44px">
Mensual:
</td>
<td style="width: 204px; height: 44px">
<asp:TextBox ID="txtNetaMensual" runat="server" Width="201px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 101px; height: 44px">
Acumulado:
</td>
<td style="width: 204px; height: 44px">
<asp:TextBox ID="txtNetaAcumulado" runat="server" Width="201px"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" style="width: 174px; height: 40px">
<b>Utilidad Neta/Ventas</b>
</td>
</tr>
<tr>
<td style="width: 101px; height: 41px">
Mensual:
</td>
<td style="width: 204px; height: 41px">
<asp:TextBox ID="txtMensual" runat="server" Width="201px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 101px; height: 41px">
Acumulado:
</td>
<td style="width: 204px; height: 41px">
<asp:TextBox ID="txtAcumulado" runat="server" Width="201px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 101px; height: 41px">
Liquidez:
</td>
<td style="width: 204px; height: 41px">
<asp:TextBox ID="txtLiquidez" runat="server" Width="201px"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" style="width: 174px; height: 40px">
<b>Acción</b>
</td>
</tr>
<tr>
<td style="width: 101px; height: 41px">
Mensual:
</td>
<td style="width: 204px; height: 41px">
<asp:TextBox ID="TextAccionMensual" runat="server" Width="201px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 101px; height: 41px">
Acumulada:
</td>
<td style="width: 204px; height: 41px">
<asp:TextBox ID="TextAccionAcumulada" runat="server" Width="201px"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" style="width: 101px; height: 41px">
<asp:Button Text="Guardar" runat="server" ID="btnSave" Width="95px" OnClick="btnSave_Click" />
</td>
</tr>
<tr>
<td colspan="2" style="width: 101px; height: 41px">
<asp:Label Text="Guardar" runat="server" ID="lblResult" Width="295px" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Now, i want to display that information on this form, i have this made, is running. doesn't give me any errors but doesn't display anything, just the blank screen:
<body>
<form id="form1" runat="server">
<div>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" XPath="datos" DataFile="Datos/DatosFinancieros.xml" />
<asp:FormView ID="FormView1" runat="server" DataSourceID="XmlDataSource1">
<ItemTemplate>
<hr />
<asp:Repeater ID="Repeater1" runat="server" DataSource='<%# XPathSelect("datos") %>'>
<ItemTemplate>
Neto Mensual:
<%# XPath("NetaMensual") %>
<br />
Neta Acumulado:
<%# XPath("NetaAcumulado") %>
<br />
<hr />
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:FormView>
</div>
</form>
Anyone has an idea what i'm doing wrong so the information isn't displayed??? Sorry for the long post but is to give a better idea of what i'm doing!

Look at the source code for your screen and see if the XML is appearing.
If it does appear, then the problem is that HTML is a variant of XML and browsers interpret anything with XML-style tags as markup rather than info.
You need to HTML-encode your XML within the <%# %> tags.
<%# Server.HtmlEncode(XPath(xyz)) %>

Related

asp.net TextBox not updating in IE11

I have migrated my .net projet from framework 3.5 to 4.5 and my the site was previously running under IE7.
I need to run it under IE11 now. I have a page which upon selecting an element in a dropdown display the values of the element selected.
The element has 3 different fields:
Code, name and info et a button delete which upon clicking delete the element and empty the fields.
Below is the code which does the reset:
protected void LB_Supprimer_Click(object sender, System.EventArgs e)
{
if ( this.DBDelete_TRF() )
{
this.TB_NOM.Text = "" ;
this.TB_CODE.Text = "" ;
this.TB_ACTCORR.Text = "" ;
}
MngMessage.refresh();
}
Code in aspx:
<TABLE id="Table1" borderColor="lightgrey" cellSpacing="5" cellPadding="0" width="100%"
border="0">
<TR>
<TD style="WIDTH: 168px; HEIGHT: 19px" align="right">
<asp:Label id="Lbl_code" runat="server" CssClass="label" DESIGNTIMEDRAGDROP="47">Code : </asp:Label></TD>
<TD style="WIDTH: 403px; HEIGHT: 19px">
<asp:TextBox id="TB_CODE" runat="server" Width="96px" CssClass="txt" DESIGNTIMEDRAGDROP="73"
ToolTip="Code" Font-Bold="True" ontextchanged="TB_CODE_TextChanged"></asp:TextBox>
</TD>
</TR>
<TR>
<TD style="WIDTH: 168px; HEIGHT: 68px" align="right">
<asp:Label id="Label_Nom" runat="server" CssClass="label" DESIGNTIMEDRAGDROP="86">Nom : </asp:Label></TD>
<TD style="WIDTH: 403px; HEIGHT: 68px">
<asp:TextBox id="TB_NOM" runat="server" Height="54px" Width="360px" CssClass="txt" DESIGNTIMEDRAGDROP="85"
Font-Bold="True" TextMode="MultiLine" Rows="4"></asp:TextBox></TD>
</TR>
<TR>
<TD style="WIDTH: 168px" align="right"></TD>
<TD style="WIDTH: 403px">
<asp:Label id="LB_INFO" runat="server" CssClass="label">Info</asp:Label></TD>
</TR>
<TR>
<TD style="WIDTH: 168px" align="right">
<asp:Label id="Label8" runat="server" CssClass="label" DESIGNTIMEDRAGDROP="49">Action : </asp:Label>
<asp:CheckBox id="chk_Confirmee" runat="server" CssClass="DBLabel" ToolTip="xxx yyy"
Text="Confirmée"></asp:CheckBox></TD>
<TD style="WIDTH: 403px">
<asp:TextBox id="TB_ACTCORR" runat="server" Height="74px" Width="360px" CssClass="txt" TextMode="MultiLine"
Rows="5"></asp:TextBox></TD>
</TR>
<TR>
<TD align="center" height="15"><cc1:linkbutton id="LB_Supprimer" runat="server" DisableText="Traitement en cours" DisableAfterClick="True" onclick="LB_Supprimer_Click">Supprimer</cc1:linkbutton></TD>
</TR>
</TABLE>
The above does not work in IE11 only but in chrome it does.
Any idea how to solve this pls?

Textbox.text not updating despite update panel

I have an online form which is used to send emails of some receivers.
I have a textbox which is prefilled with some email address. If for debug I put there some text strings (see image)
and press the send button (invia) I still see the real receivers in the tbReceivers.text field.
protected void btSend_Click(object sender, EventArgs e)
{
String txtPath = Path.Combine(Global.TxtPath, "ProssimoAllenamento.Txt");
StreamWriter sw = new StreamWriter(txtPath);
sw.Write(tbBody.Text);
sw.Close();
String strError;
if(Email.Send(tbReceivers.Text,Global.eUserType.COACH,"",tbBody.Text, tbSubject.Text, fuAttachment, out strError))
MessageBox.Show("Email inviata correttamente", this.Page, this);
else
MessageBox.Show("Errore invio email: " + strError , this.Page, this);
}
So by searching solution I found that I had to use an updatePanel, scriptmanager and include everything in a . But nothing happened.
Following my html
thanx for your help
Patrick
<%# Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" Inherits="Altro_Admin_Admin_Coach" Title="Admin Coach" CodeBehind="Admin_Coach.aspx.cs" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table style="width: 100%">
<tr>
<td style="height: 22px; width: 48px"></td>
<td style="height: 22px; width: 730px">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="X-Large" Text="Prossimo allenamento"></asp:Label>
</td>
<td style="height: 22px; width: 730px"> </td>
<td style="height: 22px; width: 730px"> </td>
<td style="height: 22px"></td>
</tr>
<tr>
<td style="width: 48px; height: 22px"></td>
<td style="width: 730px; height: 22px"></td>
<td style="width: 730px; height: 22px"> </td>
<td style="width: 730px; height: 22px"> </td>
<td style="height: 22px"></td>
</tr>
<tr>
<td style="width: 48px">Destinatari</td>
<td style="width: 730px">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:TextBox ID="tbReceivers" runat="server" Height="47px" Width="707px" Font-Size="X-Small" TextMode="MultiLine"></asp:TextBox>
</td>
<td style="width: 730px"> </td>
<td style="width: 730px"> </td>
<td> </td>
</tr>
<tr>
<td style="width: 48px; height: 29px">Oggetto</td>
<td style="width: 730px; height: 29px">
<asp:TextBox ID="tbSubject" runat="server" Height="21px" Width="707px"></asp:TextBox>
</td>
<td style="width: 730px; height: 29px"> </td>
<td style="width: 730px; height: 29px"> </td>
<td style="height: 29px"></td>
</tr>
<tr>
<td style="width: 48px; height: 11px"></td>
<td style="height: 11px; width: 730px">
<asp:TextBox ID="tbBody" runat="server" Height="344px" Width="707px" TextMode="MultiLine" Style="vertical-align: top;"></asp:TextBox>
<br />
<asp:FileUpload ID="fuAttachment" runat="server" BackColor="White" Width="715px" />
</td>
<td style="height: 11px; width: 730px"> </td>
<td style="height: 11px; width: 730px"> </td>
<td style="height: 11px"></td>
</tr>
<tr>
<td style="width: 48px; height: 41px"> </td>
<td style="height: 41px; width: 730px">
<asp:Button ID="btSend" runat="server" Height="45px" OnClick="btSend_Click" Text="INVIA" Width="714px" />
</td>
<td style="height: 41px; width: 730px"> </td>
<td style="height: 41px; width: 730px"> </td>
<td style="height: 41px"> </td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>

Align image to left is not working. Tried text-align, float, etc

Hi I am a beginner in ASP.Net. I have a web page that was working yesterday but now it's broken. I tried every solution that I found but it's not working. I'm sorry if there is a duplicate question but the solution didn't work for me.
Can you please help me.
My Code is:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link href="bootstrap.min.css" rel="stylesheet" />
<link href="bootstrap.min.js" rel="stylesheet" />
<link href="bootbox.js" rel="stylesheet" />
<link href="bootbox.min.js" rel="stylesheet" />
<link href="jquery.js" rel="stylesheet" />
<link href ="jquery-1.11.3.min.js" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="bootstrap.min.js"></script>
<script src="bootbox.min.js"></script>
<title>
</title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
height: 23px;
}
.auto-style3 {
width: 252px;
}
.auto-style4 {
height: 23px;
width: 252px;
}
.auto-style5 {
width: 381px;
}
.auto-style6 {
height: 23px;
width: 381px;
}
#ImageButton2{
position: absolute;
top: 0px;
right: -1px; }
.auto-style7 {
width: 5px;
}
.auto-style8 {
height: 23px;
width: 5px;
}
#Image2{
float:left;
text-align: left;
}
.left{
float:left;
}
.test{
float:left;
text-align: left;
}
</style>
<script type="text/javascript" lang="javascript">
function pLogin() {
var result;
bootbox.confirm("Do you have an existing account?", function (result) {
if (result == true) {
window.location.href ="/login.aspx"
}
else
{}
});
return false
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td class="auto-style7"> </td>
<td class="auto-style3"> </td>
<td class="auto-style5"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="auto-style8">
</td>
<td class="auto-style4">
<asp:ImageButton ID="ImageButton1" runat="server" Height="113px" ImageUrl="~/images/baby's logo.png" Width="407px" />
</td>
<td class="auto-style6"> </td>
<td class="auto-style2"></td>
<td class="auto-style2">
<asp:ImageButton ID="ImageButton2" runat="server" Height="111px" ImageUrl="~/images/ordernow.jpg" Width="135px" OnClientClick="javascript: return pLogin();" />
</td>
</tr>
</table>
</div>
<div>
<hr />
</div>
<div>
<p class="test">
<asp:Image ID="Image2" runat="server" Height="500px" Style="float:left" ImageUrl="~/images/puto cake.jpg" Width="960px" />
</p>
</div>
<div>
</div>
<div>
<table class="nav-justified">
<tr>
<td class="auto-style11"> </td>
<td class="auto-style22">
<asp:Label ID="Label1" runat="server" Font-Bold="False" Font-Names="Tw Cen MT Condensed Extra Bold" ForeColor="Gray" Text="ORDER" ViewStateMode="Enabled" Width="100px"></asp:Label>
</td>
<td class="auto-style22">
<asp:Label ID="Label2" runat="server" Font-Bold="False" Font-Names="Tw Cen MT Condensed Extra Bold" ForeColor="Gray" Text="CUSTOMER SERVICE" ViewStateMode="Enabled" Width="239px"></asp:Label>
</td>
<td class="auto-style16">
<asp:Label ID="Label3" runat="server" Font-Bold="False" Font-Names="Tw Cen MT Condensed Extra Bold" ForeColor="Gray" Text="MY ACCOUNT" ViewStateMode="Enabled" Width="100px"></asp:Label>
</td>
<td>
<asp:Label ID="Label4" runat="server" Font-Bold="False" Font-Names="Tw Cen MT Condensed Extra Bold" ForeColor="Gray" Text="CONNECT WITH BABY'S PUTO CAKE" ViewStateMode="Enabled" Width="317px"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style17"></td>
<td class="auto-style23">
<asp:HyperLink ID="HyperLink1" runat="server" Font-Names="Arial Black" ForeColor="Black">Puto Cake</asp:HyperLink>
</td>
<td class="auto-style23">
<asp:HyperLink ID="HyperLink2" runat="server" Font-Names="Arial Black" ForeColor="Black">Contact Us</asp:HyperLink>
</td>
<td class="auto-style20">
<asp:HyperLink ID="HyperLink3" runat="server" Font-Names="Arial Black" ForeColor="Black">Create an Account</asp:HyperLink>
</td>
<td class="auto-style21">
<asp:ImageButton ID="ImageButton3" runat="server" Height="36px" ImageUrl="~/images/Facebook-128 (1).png" Width="44px" />
<asp:ImageButton ID="ImageButton4" runat="server" Height="36px" ImageUrl="~/images/Twitter-Bird-128 (1).png" Width="44px" />
<asp:ImageButton ID="ImageButton5" runat="server" Height="36px" ImageUrl="~/images/youtube_circle_color-512.png" Width="44px" />
</td>
</tr>
<tr>
<td class="auto-style11"> </td>
<td class="auto-style22"> </td>
<td class="auto-style22"> </td>
<td class="auto-style16">
<asp:HyperLink ID="HyperLink4" runat="server" Font-Names="Arial Black" ForeColor="Black">Sign In</asp:HyperLink>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style11"> </td>
<td class="auto-style22"> </td>
<td class="auto-style22"> </td>
<td class="auto-style16"> </td>
<td> </td>
</tr>
<tr>
<td class="auto-style11"> </td>
<td class="auto-style22"> </td>
<td class="auto-style22"> </td>
<td class="auto-style16"> </td>
<td> </td>
</tr>
</table>
</div>
</form>
<div>
<br />
<br />
<br />
</div>
</body>
</html>
As I could see you didn't make you images like block elements (images are inline elements by default). Try try use display: block; or display: inline-block; in your CSS classes and then use text-align: left;.
Also floated elements could behave wrong, because they "condensed" to the content even if you use a block level element. So also try to delete float rules from CSS classes or use clear:left;.

Error : The name 'RadioButtonList1' does not exist in the current context

First Excuse me for my Bad English
This Is My code and when I Want To Run my Web , I'm getting this error: The name 'RadioButtonList1' does not exist in the current context
Session.Add("Age", TextBox1.Text.ToString());
Session.Add("Sex", RadioButtonList1.SelectedItem.Value.ToString());
Session.Add("Marr", RadioButtonList2.SelectedItem.Value.ToString());
Session.Add("Work", RadioButtonList3.SelectedItem.Value.ToString());
I remove Them And Use Radio Buttons But again getting this error
The name 'RadioButton1' does not exist in the current context
For This Code
Session.Add("Age", TextBox1.Text.ToString());
if(RadioButton1.Checked)
{
Session.Add("Sex","Male");
}
else if(RadioButton2.Checked){
Session.Add("Sex","Female");
}
if(RadioButton3.Checked)
{
Session.Add("Marr","No");
}
else if(RadioButton4.Checked){
Session.Add("Marr","Yes");
}
if(RadioButton5.Checked)
{
Session.Add("Work","Yes");
}
else if(RadioButton6.Checked){
Session.Add("Work","No");
}
Dont Getting Error For Text Box (Sorry My English is Bad :|)
I tried taking a RadioButtonList and a single button and tried this:
protected void Button1_Click(object sender, EventArgs e)
{
Session["keySession"] = RadioButtonList1.SelectedItem.ToString();
Response.Write((string)Session["keySession"]);
}
Now this is my design source:
<body>
<form id="form1" runat="server">
<div style="height: 182px">
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</div>
</form>
</body>
Can you cross check and tell me if its working?
Session["keySession"] = RadioButtonList1.SelectedItem.ToString();
Session.Add("keySession",RadioButtonList1.SelectedItem.ToString());
And these two statements will do the same work :)
I Complete C# Code Whit Auto Complete and that mean radiobutton list are defined!!!
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>DPI|پرسشنامه سنجش شخصیت وابسته</title>
<link runat="server" rel="shortcut icon" href="~/Images/favicon.ico" type="image/x-icon"/>
<style type="text/css">
*{
box-sizing: border-box;
}
body{
background: #44829B;
direction: rtl;
margin: 20px;
}
form {
background: rgba(250, 250, 250, 0.9);
box-shadow: 0 0 13px #9C9C9C,0 0 15px #F3F3F3 inset;
margin: 0 auto;
width: 60%;
border-radius: 4px;
height:auto;
overflow:hidden;
padding:10px 30px 30px 30px;
}
table {
width:100%;
border-radius: 4px;
overflow:hidden;
font-family: 'B Lotus';
font-size: large;
line-height: 50px;
vertical-align: middle;
text-align: right;
}
#Button1{
border-radius: 4px;
border-color:#666666;
border-style:Solid;
border-width:3px;
width:150px;
font-weight:800;
font-family:'B Lotus';
font-size:18px;
}
#Button1:hover {
cursor:pointer;
border-color:#44829B;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr style="text-align:center;">
<td colspan="3" style="font-family: "B Titr"; font-size: x-large">پرسشنامه شخصیت وابسته</td>
</tr>
<tr style="text-align:center;">
<td colspan="3">مشارکت کننده گرامی، قبل از پاسخ به سوالات پرسشنامه، لطفا به پرسش های زیر جواب دهید.</td>
</tr>
<tr>
<td class="auto-style5">سن :</td>
<td class="auto-style3" style="padding-right:10px;">
<asp:TextBox ID="TextBox1" runat="server" Width="42px"></asp:TextBox>
</td>
<td class="auto-style1">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="لطفا سن خود را وارد نمایید." ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style5">جنسیت :</td>
<td class="auto-style3">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal" Width="195px">
<asp:ListItem Value="Male">مرد</asp:ListItem>
<asp:ListItem Value="Female">زن</asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="RadioButtonList1" ErrorMessage="لطفا جنسیت خودرا انتخاب نمایید." ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style5">وضعیت تاهل :</td>
<td class="auto-style3">
<asp:RadioButtonList ID="RadioButtonList2" runat="server" RepeatDirection="Horizontal" Width="205px">
<asp:ListItem Value="Mojarad">مجرد</asp:ListItem>
<asp:ListItem Value="Moteahel">متاهل</asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="RadioButtonList2" ErrorMessage="لطفا وضعیت تاهل خود را مشخص نمایید." ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style5">شاغل :</td>
<td class="auto-style3">
<asp:RadioButtonList ID="RadioButtonList3" runat="server" RepeatDirection="Horizontal" Width="218px">
<asp:ListItem Value="Yes">بله</asp:ListItem>
<asp:ListItem Value="No">خیر</asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="RadioButtonList3" ErrorMessage="لطفا وضعیت شغل خود را انتخاب کنید." ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style4" colspan="3">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" Height="100px" />
<br />
</td>
</tr>
<br />
<tr>
<td class="auto-style2" colspan="3" style="text-align:center;">
<asp:Button ID="Button1" runat="server" Text="شروع ازمون" OnClick="Button1_Click" />
</td>
</tr>
</table>
</form>
</body>
</html>
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr style="text-align:center;">
<td colspan="3" style="font-family: "B Titr"; font-size: x-large">پرسشنامه شخصیت وابسته</td>
</tr>
<tr style="text-align:center;">
<td colspan="3">مشارکت کننده گرامی، قبل از پاسخ به سوالات پرسشنامه، لطفا به پرسش های زیر جواب دهید.</td>
</tr>
<tr>
<td class="auto-style5">سن :</td>
<td class="auto-style3" style="padding-right:10px;">
<asp:TextBox ID="TextBox1" runat="server" Width="42px"></asp:TextBox>
</td>
<td class="auto-style1">
</td>
</tr>
<tr>
<td class="auto-style5">جنسیت :</td>
<td class="auto-style3">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal" Width="195px">
<asp:ListItem Value="Male">مرد</asp:ListItem>
<asp:ListItem Value="Female">زن</asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
</td>
</tr>
<tr>
<td class="auto-style5">وضعیت تاهل :</td>
<td class="auto-style3">
<asp:RadioButtonList ID="RadioButtonList2" runat="server" RepeatDirection="Horizontal" Width="205px">
<asp:ListItem Value="Mojarad">مجرد</asp:ListItem>
<asp:ListItem Value="Moteahel">متاهل</asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
</td>
</tr>
<tr>
<td class="auto-style5">شاغل :</td>
<td class="auto-style3">
<asp:RadioButtonList ID="RadioButtonList3" runat="server" RepeatDirection="Horizontal" Width="218px">
<asp:ListItem Value="Yes">بله</asp:ListItem>
<asp:ListItem Value="No">خیر</asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
</td>
</tr>
<tr>
<td class="auto-style4" colspan="3">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
<br />
</td>
</tr>
<br />
<tr>
<td class="auto-style2" colspan="3" style="text-align:center;">
<asp:Button ID="Button1" runat="server" Text="شروع ازمون" OnClick="Button1_Click" />
</td>
</tr>
</table>
</form>
</body>
</html>
And the C# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Session["keyText"] = TextBox1.Text;
Session["keyGender"] = RadioButtonList1.SelectedItem.ToString();
Session["keyTwo"] = RadioButtonList2.SelectedItem.ToString();
Session["keyThree"] = RadioButtonList3.SelectedItem.ToString();
}
}

how to use the img tag

i am a student working in an simple application and i do not know how to use the img tag and i have tryed one such code but while executing the code the image is not showing plz see the code and help me to saw what is the wrong in the code.
code is:
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<table border="0" align="center" cellpadding="0" cellspacing="0" style="width: 100%;
height: 100%;">
<tr style="width: 100%; height: 300px;">
<td valign="middle" align="center">
<img alt="" src="C:\Documents and Settings\temp.intern1\My Documents\My Pictures\images4.jpg" />
</td>
</tr>
<tr style="height: 65%; vertical-align: top;">
<td style="width: 90%;" align="center">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="height: 20px">
</td>
</tr>
<tr>
<td align="center" valign="middle" width="100%" style="height: 100%">
<div id="Panel1" style="background-color: #87BDEF; height: 300px; width: 600px;">
<table cellpadding="0" cellspacing="0" style="height: 400px" width="600px">
<tr>
<td>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0" style="height: 200px" width="600px">
<tr>
<td align="right" style="padding-left: 5px; width: 50%;">
<asp:Label ID="lblUserName" runat="server" Text="USER NAME :"></asp:Label>
</td>
<td align="left" style="padding-left: 5px; width: 50%;">
<br />
<asp:TextBox ID="txtUserName" runat="server" Width="70%"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvUserName" ErrorMessage="Please enter Username"
ControlToValidate="txtUserName" runat="server" Width="70%" ForeColor="red" Style="margin-left: 0px;" />
</td>
</tr>
<tr>
<td>
<br />
</td>
<td>
<br />
</td>
</tr>
<tr>
<td align="right" style="width: 50%;">
<asp:Label ID="lblPassword" runat="server" Text="PASSWORD :"></asp:Label>
</td>
<td align="left" style="padding-left: 5px; width: 50%;">
<br />
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Width="70%"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvPassword" ErrorMessage="Please enter Password"
ControlToValidate="txtPassword" runat="server" Width="70%" ForeColor="red" Style="margin-left: 0px" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<span id="lblInValid" style="color: #C00000; font-family: Verdana; font-size: Small;">
</span>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<table width="50%">
<tr>
<td align="left" style="padding-left: 5px; width: 50%;">
<asp:Button ID="btnSubmit" runat="server" Text="SUBMIT" OnClick="btnSubmit_Click" />
<br />
<br />
<br />
</td>
<td align="left" style="padding-left: 5px; width: 50%;">
<asp:Button ID="btnClear" runat="server" Text="CLEAR" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<br />
</td>
<td>
<br />
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td height="180px">
<br />
</td>
</tr>
<tr>
<td>
<br />
</td>
</tr>
</table>
</td>
</tr>
</table>
</asp:Content>
plz some one help me on this code...,
Your image should be in the folder accessible to your web server. Try including your image into your solution file (assuming you are using Visual Studio), and use relative path, such as "/images/image4.jpg"
Go to some web site (like www.cnn.com), view source for any page and see how they set path to img tags.
You can also use ASP.Net image tag, check out MSDN for examples and usage.
The problem is that you are using an address to an image on your computer, so that will only work when you view the page from that specific computer.
You should copy the image into the web application, for example into a folder named images, then you use that address in the image tag:
<img alt="" src="images/images4.jpg" />

Resources