Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why is my code and the browser view source code different

Status
Not open for further replies.

kisslogicgoodbye

Programmer
Mar 19, 2001
18
US
Why is my code and the "view Source" Browser code different? Where did that javascript stuff come from?

Here is my code:
Language="vb" AutoEventWireup="false" Codebehind="restaurants.aspx.vb" Inherits="restaurants.restaurants1"%>
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML>
<HEAD>
<title>Restaurants</title>
<meta content=&quot;Microsoft Visual Studio.NET 7.0&quot; name=&quot;GENERATOR&quot;>
<meta content=&quot;Visual Basic 7.0&quot; name=&quot;CODE_LANGUAGE&quot;>
<meta content=&quot;VBScript&quot; name=&quot;vs_defaultClientScript&quot;>
<meta content=&quot; name=&quot;vs_targetSchema&quot;>
</HEAD>
<body bgColor=&quot;#bbbbee&quot; MS_POSITIONING=&quot;GridLayout&quot;>
<form id=&quot;Form1&quot; method=&quot;post&quot; runat=&quot;server&quot;>
<asp:datagrid id=DataGrid1 style=&quot;Z-INDEX: 101; LEFT: 21px; POSITION: absolute; TOP: 24px&quot; runat=&quot;server&quot; AutoGenerateColumns=&quot;False&quot; DataSource=&quot;<%# dsRestaurants1 %>&quot; DataMember=&quot;Restaurant&quot; DataKeyField=&quot;Restaurant_ID&quot; Height=&quot;596px&quot; Width=&quot;817px&quot; OnSortCommand=&quot;DataGrid1_SortCommand&quot; AllowSorting=&quot;True&quot; BackColor=&quot;#CCCCCC&quot; BorderColor=&quot;#999999&quot; ForeColor=&quot;Black&quot;>
<SelectedItemStyle Font-Bold=&quot;True&quot; ForeColor=&quot;White&quot; BackColor=&quot;#000099&quot;></SelectedItemStyle>
<ItemStyle BackColor=&quot;White&quot;></ItemStyle>
<HeaderStyle Font-Bold=&quot;True&quot; ForeColor=&quot;White&quot; BorderStyle=&quot;Outset&quot; BackColor=&quot;Black&quot;></HeaderStyle>
<FooterStyle BackColor=&quot;#CCCCCC&quot;></FooterStyle>
<Columns>
<asp:EditCommandColumn ButtonType=&quot;PushButton&quot; UpdateText=&quot;Update&quot; CancelText=&quot;Cancel&quot; EditText=&quot;Edit&quot;></asp:EditCommandColumn>
<asp:BoundColumn DataField=&quot;Name&quot; SortExpression=&quot;Name&quot; HeaderText=&quot;Name&quot;></asp:BoundColumn>
<asp:BoundColumn DataField=&quot;Type&quot; SortExpression=&quot;Type&quot; HeaderText=&quot;Type&quot;></asp:BoundColumn>
<asp:TemplateColumn SortExpression=&quot;PriceRageLow&quot; HeaderText=&quot;Price Range Low&quot;>
<ItemTemplate>
<asp:Label id=Label1 runat=&quot;server&quot; Text='<%# DataBinder.Eval(Container, &quot;DataItem.PriceRageLow&quot;, &quot;{0:C}&quot;) %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id=TextBox1 runat=&quot;server&quot; Width=&quot;149px&quot; Text='<%# DataBinder.Eval(Container, &quot;DataItem.PriceRageLow&quot;, &quot;{0:C}&quot;) %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression=&quot;PriceRangeHigh&quot; HeaderText=&quot;Price Range High&quot;>
<ItemTemplate>
<asp:Label id=Label2 runat=&quot;server&quot; Text='<%# DataBinder.Eval(Container, &quot;DataItem.PriceRangeHigh&quot;, &quot;{0:C}&quot;) %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id=TextBox2 runat=&quot;server&quot; Width=&quot;156px&quot; Text='<%# DataBinder.Eval(Container, &quot;DataItem.PriceRangeHigh&quot;, &quot;{0:C}&quot;) %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle HorizontalAlign=&quot;Left&quot; ForeColor=&quot;Black&quot; BackColor=&quot;#CCCCCC&quot; Mode=&quot;NumericPages&quot;></PagerStyle>
</asp:datagrid></form>
</body>
</HTML>

When I run my little program and view source this is what I get:

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML>
<HEAD>
<title>Restaurants</title>
<meta content=&quot;Microsoft Visual Studio.NET 7.0&quot; name=&quot;GENERATOR&quot;>
<meta content=&quot;Visual Basic 7.0&quot; name=&quot;CODE_LANGUAGE&quot;>
<meta content=&quot;VBScript&quot; name=&quot;vs_defaultClientScript&quot;>
<meta content=&quot; name=&quot;vs_targetSchema&quot;>
</HEAD>
<body bgColor=&quot;#bbbbee&quot; MS_POSITIONING=&quot;GridLayout&quot;>
<form name=&quot;Form1&quot; method=&quot;post&quot; action=&quot;restaurants.aspx&quot; id=&quot;Form1&quot;>
<input type=&quot;hidden&quot; name=&quot;__EVENTTARGET&quot; value=&quot;&quot; />
<input type=&quot;hidden&quot; name=&quot;__EVENTARGUMENT&quot; value=&quot;&quot; />
<input type=&quot;hidden&quot; name=&quot;__VIEWSTATE&quot; value=&quot;aaa to zzz&quot; />

<script language=&quot;javascript&quot;>
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform = document.Form1;
theform.__EVENTTARGET.value = eventTarget;
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>

<table cellspacing=&quot;0&quot; rules=&quot;all&quot; bordercolor=&quot;#999999&quot; border=&quot;1&quot; id=&quot;DataGrid1&quot; style=&quot;color:Black;background-color:#CCCCCC;border-color:#999999;height:596px;width:817px;border-collapse:collapse;Z-INDEX: 101; LEFT: 21px; POSITION: absolute; TOP: 24px&quot;>
<tr style=&quot;color:White;background-color:Black;border-style:Outset;font-weight:bold;&quot;>
<td> </td><td><a href=&quot;javascript:__doPostBack('DataGrid1:_ctl1:_ctl0','')&quot; style=&quot;color:White;&quot;>Name</a></td><td><a href=&quot;javascript:__doPostBack('DataGrid1:_ctl1:_ctl1','')&quot; style=&quot;color:White;&quot;>Type</a></td><td><a href=&quot;javascript:__doPostBack('DataGrid1:_ctl1:_ctl2','')&quot; style=&quot;color:White;&quot;>Price Range Low</a></td><td><a href=&quot;javascript:__doPostBack('DataGrid1:_ctl1:_ctl3','')&quot; style=&quot;color:White;&quot;>Price Range High</a></td>
</tr><tr style=&quot;background-color:White;&quot;>
<td><input type=&quot;submit&quot; name=&quot;DataGrid1:_ctl2:_ctl0&quot; value=&quot;Edit&quot; /></td><td>American Grill at Galleria</td><td>Italian</td><td>
<span id=&quot;DataGrid1__ctl2_Label1&quot;>$7.00</span>
</td><td>
etc.
 
The beauty of ASP.NET. Most of the features of this new technology results in a set of functions written in a script language (that you can choose, javascript by default).

hth
 
That's what the net framework is all about. It takes your code on the server side and generates standard HTML and Javascript back to the browser. That's how server side code is able to work without having to do a lot of extra versions for each browser. It's a great solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top