Solved

Getiing info from HTML components

Posted on 2004-08-24
6
166 Views
Last Modified: 2010-04-15
Hi All,

I have a ASPX page with a <div> and a <panel>.

In my code I gegerate a table on the fly and place it inside the panel.

The table has check boxes in it and there is javascript to handle the turning of checkboxes on and off ...

I now want to know if when I press an <asp:button> how do I get the state of which of the check boxes were pressed.

I also need to know, if I decide im y C# code to change the boxes that were checked, how do I send that info back to the page ...

Txs
Peter
0
Comment
Question by:Pete2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 3

Accepted Solution

by:
nhewitt21 earned 500 total points
ID: 11882988
code that goes in datagrid to make checkbox:
<ItemTemplate>
      <asp:Label id="DeleteCheckBox" text='<%#"<input class=\"search\" type=\"checkbox\" name=\"DeleteCB" + (DataBinder.Eval(Container.DataItem,"ID").ToString()) + "\" value=\"" + (DataBinder.Eval(Container.DataItem,"ID").ToString()) + "\"/>"%>' runat="server" /></ItemTemplate>

i have an input button:
<input id="DelSelected" name="DelSelected" runat="server">

in my codebehind:
private void DelSelected_ServerClick(object sender, System.Web.UI.ImageClickEventArgs e)
{
      foreach (string var in Request.Form)
      {
            if (var.IndexOf("DeleteCB") > -1)
            {
                  //calls function that removes item from database (via id)                  
                  DeleteFromPhotoAlbum(Convert.ToInt32(Request.Form[var].ToString()));

thats how i did it, there a bit more code
            }
      }
}

That works ok.
hope it helps you out.
0
 
LVL 3

Expert Comment

by:nhewitt21
ID: 11883028
private void DelSelected_ServerClick(object sender, System.Web.UI.ImageClickEventArgs e)
{
     foreach (string var in Request.Form)
     {
          if (var.IndexOf("DeleteCB") > -1)
          {
               //calls function that removes item from database (via id)              
               DeleteFromPhotoAlbum(Convert.ToInt32(Request.Form[var].ToString()));
          }
     }
}
0
 
LVL 3

Expert Comment

by:nhewitt21
ID: 11883081
and this:
this.DelSelected.ServerClick += new System.Web.UI.ImageClickEventHandler(this.DelSelected_ServerClick);

needs to go inside the InitializeComponent() for the OnInit
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Pete2003
ID: 11889919
Hi,

Thanks for the info I'm however lost right at the beginning .. what is the <itemTemplate> stuff ??

The way I did my table is just simple generation within a <panel> ...

0
 
LVL 3

Expert Comment

by:nhewitt21
ID: 11890113
ahh, i have misunderstood what you was trying to do.  I had assumed you was using a datagrid.  My bad, sorry.

The item template just creates a template column in the datagrid and puts checkboxexs in each row.  If your using a table then forget the template bit and the rest of the code should be enough for you to do what you need to do.
0
 

Author Comment

by:Pete2003
ID: 11892768
Ok I am really trying hard to understand how you are working this, but to no avail ...

There is no relevant data in the Request.Form as the table is in a panel which does not even appear in the form ...

Here is my ASPX page:

<DIV style="WIDTH: 791px; POSITION: relative; HEIGHT: 140px" ms_positioning="GridLayout"
      id="div1" runat="server">&nbsp;
      <asp:panel id="tablePanel" style="Z-INDEX: 102; LEFT: 0px; OVERFLOW: auto; POSITION: relative"
            Height="200px" Width="100%" Runat="server"></asp:panel>
</DIV>

I now use my codebehind to populate the tablePanel with a LiteralControl containing the HTML Table:
ie:

string sHTML = "<table><tr><td>Hello</td><td>Hello</td></tr></table>";
tablePanel.Controls.Add(new LiteralControl(sHTML));

Now I need to be able to access the "Hello" and "World" from my C# code ...

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question