using jquery
Populate with jquery and Javascript an asp.net controll
and not Losing Values after Postback
The following code snippet defines and implements these events and their respective event handlers. You can write this code to implement CheckedChanged event dynamically.
Image in RadioButton
The Image property of a RadioButton control is used to set the background as an image. The Image property needs an Image object. The Image class has a static method called FromFile that takes an image file name with full path and creates an Image object.
You can also align image and text. The ImageAlign and TextAlign properties of RadioButton are used for this purpose.
The following code snippet sets an image as a RadioButton background.
dynamicRadioButton.Image = Image.FromFile(@"C:\Images\MYIMG.jpg");
dynamicRadioButton.ImageAlign = ContentAlignment.MiddleRight;
dynamicRadioButton.FlatStyle = FlatStyle.Flat;
dynamicRadioButton.CheckedChanged += new System.EventHandler(RadioButtonCheckedChanged);
private void RadioButtonCheckedChanged(object sender, EventArgs e)
{
}
protected void Page_Load(object sender, EventArgs e)
{
Panel1.Visible = false;
Panel2.Visible = false;
Panel3.Visible = false;
Panel4.Visible = false;
if (!IsPostBack)
{
if (Request.QueryString != null)
{
Label1.Text = Request.QueryString["ss"].ToString();
}
}
}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
if (Request.QueryString["ss"] == "new")
{
Panel1.Visible = true;
Panel2.Visible = false;
}
if (Request.QueryString["ss"] == "old")
{
Panel3.Visible = true;
Panel4.Visible = false;
}
}
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
jquery Javascript code
1.using System;
1.using System.Collections.Generic;
2.using System.Web;
3.using System.Web.UI;
4.using System.Web.UI.WebControls;
5.
6.public partial class ListBoxOperator : System.Web.UI.UserControl
7.{
8. protected char _delimiter = '|';
9. private string _title = string.Empty;
10.
11. public char Delimiter
12. {
13. get { return _delimiter; }
14. set { _delimiter = value; }
15. }
16.
17. public string Title
18. {
19. get { return _title; }
20. set { _title = value; }
21. }
22.
23. protected void Page_Init(object sender, EventArgs e)
24. {
25. hidListBox.Value = _delimiter.ToString();
26. litTitle.Text = _title;
27. }
28.
29. protected void Page_Load(object sender, EventArgs e)
30. {
31.
32. }
33.
34. public ListItemCollection Items
35. {
36. get
37. {
38. char[] seperator = new char[1] { _delimiter };
39. string[] lstBox = hidListBox.Value.Split(seperator, StringSplitOptions.RemoveEmptyEntries);
40. ListItemCollection lstItemCollection = new ListItemCollection();
41. for (int i = 0; i < lstBox.Length; i++) 42. { 43. lstItemCollection.Add(new ListItem(lstBox[i])); 44. } 45. return lstItemCollection; 46. } 47. set 48. { 49. lstBox.Items.Clear(); 50. hidListBox.Value = _delimiter.ToString(); 51. for (int i = 0; i < value.Count; i++) 52. { 53. lstBox.Items.Add(new ListItem(value[i].Text, value[i].Value)); 54. hidListBox.Value += value[i].Value + _delimiter; 55. } 56. } 57. } 58.}And that's it! var list = ","; $(':input:radio').each( function() { if(this.checked == true) { var arr = this.name.split("$"); var IdEl = arr[arr.length-1]; list += IdEl + ":" + this.value + ","; } }); // $('#h_checks').val(list); $hidlist.val(list); return true; asp:HiddenField ID="h_checks" runat="server" script var $hidlist = $('#<%= h_checks.ClientID %>');
script
server side params from server sideu can use an attribute.
like this code that work :
$("#elementId").val("value");
asp.net c# loop for all radiobuttons
loop through multiple radio buttons
foreach (RadioButton X in groupBoxX.Controls)
{
//SOME LOGIC
}
protected void Save_Click(object sender, EventArgs e)
{
// foreach (FormDataSet.SectionsRow rowSection in dsForm.Sections.Rows)
DYANICALY GET SER OR JUST ADD CONTROLS LIKE RADIO BUTTONS
foreach (Control c in Panel1.Controls)
{
if (c is TextBox)
{
TextBox txtResponse = c as TextBox;
Response.Write(txtResponse.ID.ToString() );
Response.Write("
");
Response.Write(txtResponse.Text.ToString());
Response.Write("
");
}
if radiobutton clicked then panel panel is visible
private void radiobutton1 _CheckedChanged(object sender, EventArgs e)
{
Panel panel2 = getpanel.getPanelNonProd();
Panel panel1 = getpanel.getPanelProd();
panel2.Visible = false;
panel1.Visible = true;
}
c# visable false to all radiobuttons
private void radiobutton2_CheckedChanged(object sender, EventArgs e)
{
Panel panel2 = getpanel.getPanelNonProd();
Panel panel1 = getpanel.getPanelProd();
panel2.Visible = true;
panel1.Visible = false;
}
asp.net if radiobutton is checked turn on picture
Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim myControl As Control
For Each myControl In Me.pan1.Controls
If myControl.GetType().FullName = "System.Web.UI.WebControls.RadioButton" Then
Dim myRadioButton As RadioButton = CType(myControl, RadioButton)
If XRadioButton.GroupName = "rgColor" Then
If XRadioButton.Checked Then
Me.txtShowSel.Text = "You Selected the Color: " & XRadioButton.Text
End If
End If
End If
Next
End Sub
foreach controls c convert to div as server control
foreach (Control c in Panel1.Controls)
{
if (c is TextBox)
{
TextBox txtResponse = c as TextBox;
//SDO SOMTHING
}
}
Getting the Values of Controls on the Master Page
// Gets a reference to a TextBox control inside a ContentPlaceHolder
ContentPlaceHolder mpContentPlaceHolder;
TextBox mpTextBox;
mpContentPlaceHolder =
(ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
if(mpContentPlaceHolder != null)
{
mpTextBox = (TextBox) mpContentPlaceHolder.FindControl("TextBox1");
if(mpTextBox != null)
{
mpTextBox.Text = "TextBox found!";
}
}
// Gets a reference to a Label control that is not in a
// ContentPlaceHolder control
Label mpLabel = (Label) Master.FindControl("masterPageLabel");
if(mpLabel != null)
{
Label1.Text = "Master page label = " + mpLabel.Text;
}
You can access the contents of the master page's ContentPlaceHolder controls by using the FindControl method, as shown above. If the ContentPlaceHolder control has been merged with content from a Content control, the ContentPlaceHolder control will not contain its default content. Instead, it will contain the text and controls that are defined in the content page.
<%@ Page Language="C#" Title="Content Page" MasterPageFile="~/MasterBlue.master"%>
<%@ MasterType TypeName="BaseMaster" %>
Content from Content page.
next articles will be according to
asp.net
javascript
download
firefox
css
css reference
developer tools