?
Solved

Getiing info from HTML components

Posted on 2004-08-24
6
Medium Priority
?
167 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 2000 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

752 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