Solved

Getiing info from HTML components

Posted on 2004-08-24
6
161 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
  • 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now