Showing posts with label runat. Show all posts
Showing posts with label runat. Show all posts

Saturday, March 31, 2012

Table. Look Everywhere. Please help me out.

Hello,

I need to create a Table at runtime and I need the TBody tag to be:

<tbody id="itemContainer" runat="server"></tbody>

I need to to define its ID and making it run at server.

I tried everthing I could think of.

How can I do this?

Thanks,

Miguel

you can use a placeholder and do a placeholder.controls.add(pass the tablehere, table is your server object)


You didn't understand. I have no problems in working at runtime.

I create everything at runtime. The problem is that I can't find a property/way to define the ID of a Table's TBody tag when created at runtime.

Thanks,

Miguel


Hi Miguel,

Based on my understanding, you want to add the table in your asp.net application dynamically. If I have misunderstood you, please feel free to let me know.

The tbody is the html control. We can add the server table dynamically. For example,

Table t = new Table();
t.ID = "t";
TableHeaderRow hr = new TableHeaderRow();
hr.ID = "hr";
t.Controls.Add(hr);
TableCell tc = new TableCell();
tc.ID = "tc";
hr.Controls.Add(tc);
tc.Text = "test";

form1.Controls.Add(t);


I hope this helps.


publicvoid CreateEmployeeList()

{

System.Web.UI.WebControls.Table Tab =new System.Web.UI.WebControls.Table();

Tab.BorderWidth =newUnit(3);

Tab.BorderColor = System.Drawing.Color.AliceBlue;

Tab.CellPadding = 1;

//Tab.CellSpacing = 1;

TableRow Tr =newTableRow();

TableCell Tc1 =newTableCell();

TableCell Tc2 =newTableCell();

TableCell Tc3 =newTableCell();

TableCell Tc4 =newTableCell();

Label label4 =newLabel();

label4.ID ="label4";

label4.Text ="Employee ID";

Tc4.Controls.Add(label4);

Tr.Cells.Add(Tc4);

Label label1 =newLabel();

label1.ID ="label1";

label1.Text ="Employee";

Tc1.Controls.Add(label1);

Tr.Cells.Add(Tc1);

Label label2 =newLabel();

label2.ID ="label2";

label2.Text ="Attendance";

Tc2.Controls.Add(label2);

Tr.Cells.Add(Tc2);

Label label3 =newLabel();

label3.ID ="label3";

label3.Text ="Remark";

Tc3.Controls.Add(label3);

Tr.Cells.Add(Tc3);

Tab.Rows.Add(Tr);

Tr.BackColor = System.Drawing.Color.AliceBlue;

EmployeeList =EmployeeReg.SelectStaff();

EmployeeReg empreg;

EmployeeNo = EmployeeList.Count;

Empid =newLabel[EmployeeList.Count];

Empname =newLabel[EmployeeList.Count];

Attendance =newRadioButtonList[EmployeeList.Count];

Remark =newTextBox[EmployeeList.Count];

for (int i = 0; i < EmployeeList.Count; i++)

{

empreg =newEmployeeReg();

empreg = EmployeeList[i];

//initialize table row

Tr =newTableRow();

//initialize columns in particular row

Tc1 =newTableCell();

Tc2 =newTableCell();

Tc3 =newTableCell();

Tc4 =newTableCell();

//Generating Employee ID in table.

Label Lbl2 =newLabel();

Lbl2.ID ="lblEmpid" + i.ToString();

Lbl2.BackColor= System.Drawing.Color.AliceBlue;

Lbl2.Text = empreg.EmployeeID.ToString();

Empid[i] = Lbl2;

Tc4.Controls.Add(Lbl2);

Tr.Cells.Add(Tc4);

//Generating Employee name in table.

Label Lbl1 =newLabel();

Lbl1.ID ="lblName" + i.ToString();

Lbl1.Text = empreg.EmployeeName.ToString();

Empname[i] = Lbl1;

Tc1.Controls.Add(Lbl1);

Tr.Cells.Add(Tc1);

//Genertaing radiobuttonlist for attendance

RadioButtonList rdbl =newRadioButtonList();

rdbl.ID ="rdblAtt" + i.ToString();

rdbl.RepeatDirection =RepeatDirection.Horizontal;

ListItem item1 =newListItem();

//item1.Text = "Present";

item1.Value ="P";

item1.Selected =true;

rdbl.Items.Add(item1);

ListItem item2 =newListItem();

// item2.Text = "Absent";

item2.Value ="A";

rdbl.Items.Add(item2);

ListItem item3 =newListItem();

// item3.Text = "Off Day";

item3.Value ="O";

rdbl.Items.Add(item3);

ListItem item4 =newListItem();

// item4.Text = "Half Day";

item4.Value ="H";

rdbl.Items.Add(item4);

Attendance[i] = rdbl;

Tc2.Controls.Add(rdbl);

Tr.Cells.Add(Tc2);

//Genertaing TextBox for Remark

TextBox Txt1 =newTextBox();

// Txt1.ID = "txtRemark" + i.ToString();

Remark[i] = Txt1;

Remark[i].ID ="txtRemark" + i.ToString();

Remark[i].Text ="";

Tc3.Controls.Add(Txt1);

Tr.Cells.Add(Tc3);

Tab.Rows.Add(Tr);

}

this.Panel1.Controls.Add(Tab);

}

Saturday, March 24, 2012

Tabstrip dynamic functionality ?

Ive added a tabstrip to my code (see below code):


<iewc:TabStrip id="myTabStrip" runat="server" TabDefaultStyle="background-color:#d3d3d3; border:solid 1px black; font-family:verdana; font-weight:bold; font-size:8pt; color:#ffffff; width:79; height:21; text-align:center"
SepDefaultStyle="width:10px; border-bottom: solid 1px black;" TabHoverStyle="background-color:#d3d3d3"
TabSelectedStyle="background-color:#ffffff;color:#000000" Width="100%" Height="24px" AutoPostBack="True">
<iewc:Tab></iewc:Tab>
<iewc:TabSeparator></iewc:TabSeparator>
<iewc:Tab TabIndex="1"></iewc:Tab>
<iewc:TabSeparator></iewc:TabSeparator>
<iewc:Tab TabIndex="2"></iewc:Tab>
<iewc:TabSeparator></iewc:TabSeparator>
<iewc:Tab TabIndex="3"></iewc:Tab>
</iewc:TabStrip>

This works fine, but what I really want to do is dynamically add / remove tabs depending on records in a database. For example if a table in a database has 5 records, then the tabstrip displays 5 tabs, if it holds 3 records then the tabstrip displays 3 tabs.

Is this possible ?? If so, how do I go about doing this in codebehind ?

thanks
ferkh10.This post should shed some light:view post 437723

Also, there is a forum for the Internet Explorer Web Controls:view forum 91. That is a good place to ask questions related to the TabStrip and TreeView controls.

Terri

tag not well formed with java and quotes problem

Here is the tag:

<asp:Image ID="Photo" runat="server" ImageUrl="Images/Loading.gif" OnLoad="SwapImage(this,'Handler.ashx?AlbumID=<%#Eval("AlbumID")%>&Size=M');" CssClass="photo_198" style="border:4px solid white" ToolTip='<%#Eval("DESCRIPTION")%>' />

I know the problem is something with the OnLoad part of the tag. and I'm pretty sure it has to do with the single quotes around the handler url. can anyone help with this? do I need to escape out of the single quote or what?

Try this

<asp:Image ID="Photo" runat="server" ImageUrl="Images/Loading.gif" OnLoad='SwapImage(this,<%# "Handler.ashx?AlbumID=" & Eval("AlbumID")%>&"Size=M");' CssClass="photo_198" style="border:4px solid white" ToolTip='<%#Eval("DESCRIPTION")%>' />
I dont have the swapImage function, so I'm not sure if it's working or not, but the error changed :)

onmouseover="<%#"javascript:clearHistory1('" & Eval("Heading") & "','" & Eval("Description") & "');"%>"


niether of those two helped, the 2nd on gives a worse error and I'm not doing a roll over image. Here is my swapImage function

 <script type="text/javascript"> function SwapImage(img,src) { img.src=src; } </script>

this is what I changed the onload part to and still get the not well formed tag error:

<asp:Image ID="Photo" runat="server" ImageUrl="Images/Loading.gif" OnLoad='<%#"SwapImage(this, 'Handler.ashx?AlbumID=" + Eval("AlbumID") +"&Size=M')"%>' CssClass="photo_198" style="border:4px solid white" ToolTip='<%#Eval("DESCRIPTION")%>' />

ASP:Image is a server side control, when you specify the onload event, it's looking for a server onload event, not a JavaScript event which is client side.

<imgonload="SwapImage(this,<%# "handler.ashx?AlbumID=" & Eval("AlbumID") & "&Size=M" %>);"src="Images/loading.gif"class="photo_198"style="border:4px solid white"ToolTip='<%#Eval("Description")%>'/>

You need a client side HTML tag like above, who's onload even will fire on the client side, not the server side.

Hope this helps.


here is the other way is wrote the Onload part and got the same error:

OnLoad="SwapImage(this, 'Handler.ashx?AlbumID=<%# Eval("AlbumID") %>&Size=M')"


thanks a lot!!! It works great! I just needed to change the onload function in the swapImage function


it looks great in firefox but in IE 7.0 the animation of the loading gif never animates and just shows the first frame. The actual image load above it, but IE says there is an error on the page and says the error is "Error: object expected"


I fixed the Error but in IE I still don't get any animation from the loading.gif, anyone know why?


It's almost assurendly a problem with your handler. Can you post the code to the handler you're using to retreive the image?


the handler returns the correct image fine. The website runs perfect with animation in firefox but IE 7.0 just stops the animation of the loading.gif at the first frame

Tuesday, March 13, 2012

TARGET BLANK QUESTION

I would like the following link to open in a new page at a certain size, e.g 400px by 400px any ideas??

class="link" id="paints" runat="server" target="_blank" href='<%# String.Format( "details.aspx?id={0}", Container.DataItem( "ProductID" ) ) %>'>Link

thanksBeer [B]

Check out this page for the window.open method:

http://www.devguru.com/Technologies/ecmascript/quickref/win_open.html


hiya thanks for your help however I am unsure where I would put that information in my new page, the new page code I have already is.... thanks

<%@. Page Language="VB" %>
<%@. import Namespace="System.Data" %>
<%@. import Namespace="System.Web.UI.WebControls.Image" %>
<%@. import Namespace="System.Data.OleDb" %>
<script runat="server">

Sub Page_Load
Dim intProductID As Integer
Dim conMurraysdb As OleDbConnection
Dim strSelect As String
Dim cmdSelect As OleDbCommand
Dim dtrResult As OleDbDataReader


intProductID = Int32.Parse( Request.QueryString( "id" ) )


conMurraysdb = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=D:\Domains\murraysfordesign.co.uk\db\Murraysdb.mdb" )
strSelect = "Select * From Products WhereProductID=@.ProductID"
cmdSelect = New OleDbCommand( strSelect, conMurraysdb )
cmdSelect.Parameters.Add( "@.ProductID", intProductID )
conMurraysdb.Open()
dtrResult = cmdSelect.ExecuteReader( CommandBehavior.SingleRow )


If dtrResult.Read Then
lblResult.Text = dtrResult( "Product" )
lblPrice.Text = dtrResult( "price" )
lblSize.Text = dtrResult( "size" )
lblDescription.Text = dtrResult( "Description" )
img_product.ImageURL = dtrResult( "Image_url" )

End If

dtrResult.Close()
conMurraysdb.Close()
End Sub

</script>
<html>
<head>
<title>Details.aspx</title>
</head>
<body>
<form runat="Server">
<table height="450" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td colspan="3" height="20">

</td>
</tr>
<tr>
<td valign="top" width="120">
</td>
<td valign="top" width="338">
<p style="FONT-SIZE: 13px; COLOR: #cc3333; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif">
<b><asp:Label id="lblResult" runat="Server" font-size="12px" font-bold="True" font-names="Verdana, Arial, Helvetica, sans-serif"></asp:Label></b>
</p>
<br />
<p style="FONT-SIZE: 11px; COLOR: #333333; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif">
Description:
</p>
<blockquote><asp:Label id="lblDescription" runat="Server" font-size="11px" font-names="Verdana, Arial, Helvetica, sans-serif"></asp:Label></blockquote> <blockquote><asp:Label id="lblSize" runat="Server" font-size="11px" font-names="Verdana, Arial, Helvetica, sans-serif"></asp:Label></blockquote> <blockquote>£ <asp:Label id="lblPrice" runat="Server" font-size="11px" font-names="Verdana, Arial, Helvetica, sans-serif"></asp:Label></blockquote></td>
<td valign="top" width="342">
<asp:Image id="img_product" runat="server"></asp:Image>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>