RadioButtonList alignment issue - c#

I have a below code based on the value from backend i have to display the radiobuttonlist listitem value and controls in aspx page.
when the rbl1.SelectedValue = "0" the alignmnet of the controls are fine.
when the rbl1.SelectedValue = "1" the RadioButtonList is coming to center like below, and i want this rbl to align left side only.
can any body help me in this.
C#:
public string HiddenClassName { get; private set; }
if (!string.IsNullOrEmpty(value) && value.ToLower() == "y")
{
rbl1.SelectedValue = "0"; //Yes
lblName.Visible = true;
txtName.Visible = true;
HiddenClassName = "display:block";
}
else
{
rbl1.SelectedValue = "1"; //No
lblName.Visible = false;
txtName.Visible = false;
HiddenClassName = "display:none";
}
ASPX:
<h2>
Information</h2>
<table width="100%">
<tr>
<td>
<asp:Label ID="lbl1" runat="server" Width="180px" Text="Would like to use?"></asp:Label>
</td>
<td >
<asp:RadioButtonList ID="rbl1" runat="server" TextAlign="Right" RepeatDirection="Horizontal">
<asp:ListItem Value="Yes" Text="Yes" Selected="True" />
<asp:ListItem Value="No" Text="No" />
</asp:RadioButtonList>
</td>
<td style="padding-bottom: 17px">
<%=this.ShowHelp("rbl_Help")%>
</td>
<%-- <asp:Panel ID="pnlAgntName" runat="server"> --%>
<td align="right">
<asp:Label ID="lblName" Text="Name" runat="server"></asp:Label>
</td>
<td align="left">
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</td>
<td style="<%= HiddenClassName %>;padding-bottom: 17px">
<%=this.ShowHelp("Name_Help")%>
</td>
<%--</asp:Panel>--%>
</tr>
</table>
<div class="hr">
</div>
</fieldset>

Add width in each td like style="width: 25px"

Related

how to use both scriptmanger and ajaxtoolscript manager in one single aspx page?

I tried to use update panel in aspx page to avoid page refresh after button click event but in my code I used Ajax rating control for that i used asp:ToolkitScriptManager but for update panel I added scriptmanager its showing error "only one instance of a scriptmanager can be added to the page".without ajaxtoolkit rating wont work.Please can anyone suggest me how to overcome from this problem and how to avoid page refresh after buttonclick.
my code:
kgis.aspx
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:HiddenField ID="currTab" runat="server" />
<asp:Panel ID="tabPanel" runat="server">
<ul>
<li><span>General Feedback</span></li>
<li><span>New Requirements</span></li>
<li><span>My Feedback</span></li>
</ul>
<%-- general feedback tab--%>
<asp:Panel ID="Panel1" runat="server">
<div class="tabcaption">General Feedback</div>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
<table class="general">
<tr>
<td style="padding-left:22px;">1.Did you find the information you were looking for?</td>
</tr>
<tr>
<td style="padding-left:30px;"> if no please explain why?</td>
</tr>
<tr >
<td style="padding-left:28px;">
<div id="RadioDiv1">
<asp:RadioButtonList ID="radiolist1" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" CssClass="radio1">
<asp:ListItem Value="yes">Yes </asp:ListItem>
<asp:ListItem Value="no">No</asp:ListItem>
</asp:RadioButtonList>
</div>
</td>
</tr>
<tr >
<td >
<div id="info" style="padding-left:64px;">Please Explain:
<asp:TextBox ID="infodesc" runat="server" CssClass="textb" TextMode="MultiLine"></asp:TextBox>
</div>
</td>
</tr>
<tr>
<td style="padding-left:22px;"> 2.Did the portal meet your need/ answer your questions?</td>
</tr>
<tr>
<td style="padding-left:30px;"> if no please explain why?</td>
</tr>
<tr >
<td style="padding-left:28px;">
<div id="RadioDiv2">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" CssClass="radio1">
<asp:ListItem Value="yes">Yes </asp:ListItem>
<asp:ListItem Value="no">No</asp:ListItem>
</asp:RadioButtonList>
</div>
</td>
</tr>
<tr >
<td >
<div id="port" style="padding-left:64px;">Please Explain:
<asp:TextBox ID="portdesc" runat="server" CssClass="textb" TextMode="MultiLine"></asp:TextBox>
</div>
</td>
</tr>
<tr><td style="padding-left:22px;">3.Please rate these</td>
</tr>
<tr>
<td style="padding-left:32px;">a.GUI</td>
<td>
<asp:Rating ID="Rating1" runat="server" BehaviorID="RatingBehavior1" CssClass="textb"
MaxRating="5"
StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar1"
FilledStarCssClass="filledRatingStar1"
EmptyStarCssClass="emptyRatingStar1"
OnChanged="ThaiRating_Changed"
Style="float: left;" />
</td>
</tr>
<tr>
<td style="padding-left:32px;">b.Correctness of content</td>
<td>
<asp:Rating ID="Rating2" runat="server" BehaviorID="RatingBehavior2" CssClass="textb"
MaxRating="5"
StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar1"
FilledStarCssClass="filledRatingStar1"
EmptyStarCssClass="emptyRatingStar1"
OnChanged="ThaiRating_Changed"
Style="float: left;" />
</td>
</tr>
<tr>
<td style="padding-left:32px;">c.Existing functionality</td>
<td>
<asp:Rating ID="Rating3" runat="server" BehaviorID="RatingBehavior3" CssClass="textb"
MaxRating="5"
StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar1"
FilledStarCssClass="filledRatingStar1"
EmptyStarCssClass="emptyRatingStar1"
OnChanged="ThaiRating_Changed"
Style="float: left;" />
</td>
</tr>
<tr><td style="padding-left:22px;">4.Please give a feedback</td></tr>
<tr>
<td style="padding-left:34px;">
<asp:TextBox ID="msg" runat="server" CssClass="textb" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-left:22px;">5.Do you have any document/image/screenshot/slide for the new requirement reference? if yes,please upload(max 2MB)</td>
</tr>
<tr>
<td>
<asp:FileUpload ID="fileupload1" runat="server" CssClass="textb" onchange="validateFileSize();"/>
<asp:Label ID="lblMessage" Text=" " runat="server" style="color:Red;"/>
<div id="dvMsg" style="color:Red; width:195px;display:none;" >
File size is greater than 2mb </div>
</td>
</tr>
</table>
<asp:Button ID="Button1" runat="server" OnClick="btnUpload_Click" Text="Save and Continue" CssClass="btn" AutoPostback = "false"/>
<%-- <asp:Button ID="Button4" runat="server" Text="Save and Continue" CssClass="btn" OnClick="Button4_Click" />--%>
</asp:Panel>
<%-- new requirements tab--%>
<asp:Panel ID="Panel2" runat="server">
<div class="tabcaption">New requirements</div>
<table class="newrq">
<tr>
<td style="padding-left:22px;"> 1.What are your new Requirements? Please Explain: </td>
</tr>
<tr>
<td style="padding-left:53px;">
<asp:TextBox ID="newrequire" runat="server" CssClass="textb" TextMode="MultiLine" ></asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-left:22px;">2.Do you require any new functions ?</td>
</tr>
<tr >
<td style="padding-left:28px;">
<div id="RadioDiv">
<asp:RadioButtonList ID="newfunc" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" CssClass="radio1">
<asp:ListItem Value="yes">Yes </asp:ListItem>
<asp:ListItem Value="no">No</asp:ListItem>
</asp:RadioButtonList>
</div>
</td>
</tr>
<tr >
<%-- <td style="padding-left:28px;width:200px;margin-left:-220px;">Functions List</td>--%>
<td>
<div id="fundiv" style="padding-left:64px;">
Functions List:
<asp:DropDownList ID="funlist" runat="server">
<asp:ListItem runat="server" Value="no">--Select--</asp:ListItem>
<asp:ListItem runat="server" Value="yes">Reports</asp:ListItem>
<asp:ListItem runat="server" Value="yes">Charts</asp:ListItem>
<asp:ListItem runat="server" Value="yes">Graphs</asp:ListItem>
<asp:ListItem runat="server" Value="yes">Analysis</asp:ListItem>
<asp:ListItem runat="server" Value="yes">Others</asp:ListItem>
</asp:DropDownList>
</div>
</td>
</tr>
<tr><%-- <td style="padding-left:28px;width:200px;margin-left:-220px;">Please Explain</td>--%>
<td>
<div id="expdiv" style="padding-left:64px;">
Please Explain:
<asp:TextBox ID="fundesc" runat="server" CssClass="textb" TextMode="MultiLine"></asp:TextBox>
<a alt="Reports" class="tooltipDemo" href="#">
<asp:Image ID="Image3" runat="server" Height="25px" ImageUrl="images/tooltip.jpg" style="margin-top: -49px;" Width="25px" />
</a>
</div>
</td>
</tr>
<tr>
<td style="padding-left:22px;">3.What will be the input data for the requirement?</td>
</tr>
<tr>
<td style="width:385px;padding-left:53px;">
<asp:TextBox ID="inpt" runat="server" CssClass="textb" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-left:22px;">4.What should be the output data for the requirement?</td>
</tr>
<tr>
<td style="width:385px;padding-left:53px;">
<asp:TextBox ID="oupt" runat="server" CssClass="textb" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-left:22px;">5.Do you have any document/image/screenshot/slide for the new requirement reference? if yes,please upload(max 2MB)</td>
</tr>
<tr>
<td>
<asp:FileUpload ID="fileupload2" runat="server" CssClass="textb" onchange="validateFileSize1();"/>
<asp:Label ID="Label1" runat="server" ></asp:Label>
<div id="dvMsg1" style="color:Red; width:195px;display:none;" >
File size is greater than 2mb </div>
</td>
</tr>
</table>
<asp:Button ID="Button2" runat="server" Text="Save" onclick="btnUpload_Click1" CssClass="btn" />
</asp:Panel>
<%-- My feedback tab--%>
<asp:Panel ID="Panel3" runat="server">
<div class="tabcaption"> </div>
<div style="overflow:auto;">General Feedback
<asp:GridView ID="dataGridView2" runat="server" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
AutoGenerateColumns="true" OnPageIndexChanging="datagrid_PageIndexChangingimg">
</asp:GridView></div>
<br /><br />
<div style="overflow:auto;">
New Requirements
<asp:GridView ID="dataGridView3" runat="server" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
AutoGenerateColumns="true" OnPageIndexChanging="datagrid_PageIndexChangingimg1">
</asp:GridView></div>
</asp:Panel>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" />
</Triggers>
</asp:UpdatePanel>
</div>
kgis.aspx.cs
protected void btnUpload_Click(object sender, EventArgs e)
{
MimeType m = new MimeType();
HttpPostedFile file = fileupload1.PostedFile;
byte[] document = new byte[file.ContentLength];
file.InputStream.Read(document, 0, file.ContentLength);
string s = m.GetMimeType(document, file.ToString());
switch (Rating1.CurrentRating)
{
case 1:
remarks = "Poor";
break;
case 2:
remarks = "Average";
break;
case 3:
remarks = "Good";
break;
case 4:
remarks = "Very Good";
break;
case 5:
remarks = "Excellent";
break;
}
switch (Rating2.CurrentRating)
{
case 1:
remarks = "Poor";
break;
case 2:
remarks = "Average";
break;
case 3:
remarks = "Good";
break;
case 4:
remarks = "Very Good";
break;
case 5:
remarks = "Excellent";
break;
}
//string remarks2 = "[unknown]";
switch (Rating3.CurrentRating)
{
case 1:
remarks = "Poor";
break;
case 2:
remarks = "Average";
break;
case 3:
remarks = "Good";
break;
case 4:
remarks = "Very Good";
break;
case 5:
remarks = "Excellent";
break;
}
if (s.Equals("not valid file"))
{
// ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('file is not valid')", true);
//Console.WriteLine("The variable is set to true.");
Label1.Text = "file is not valid";
}
else
{
using (SqlConnection con = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand())
{
con.Open();
cmd.CommandText = "insert into FileInformation(usernm,emailID,info,infodesc,portal,portdesc,guirating,ccrating,efrating,feedback,FileName,FileType,FileData) values(#usernm,#emailID,#info,#infodesc,#portal,#portdesc,#guirating,#ccrating,#efrating,#feedback,#Name,#Type,#Data)";
cmd.Parameters.AddWithValue("#usernm", usernm);
cmd.Parameters.AddWithValue("#emailID", emailID);
cmd.Parameters.AddWithValue("#info", radiolist1.SelectedItem.Value);
cmd.Parameters.AddWithValue("#infodesc", infodesc.Text);
cmd.Parameters.AddWithValue("#portal", RadioButtonList1.SelectedItem.Value);
cmd.Parameters.AddWithValue("#portdesc", portdesc.Text);
cmd.Parameters.AddWithValue("#guirating", remarks);
cmd.Parameters.AddWithValue("#ccrating", remarks);
cmd.Parameters.AddWithValue("#efrating", remarks);
cmd.Parameters.AddWithValue("#feedback", msg.Text);
cmd.Parameters.AddWithValue("#Name", file.FileName);
cmd.Parameters.AddWithValue("#Type", s);
cmd.Parameters.AddWithValue("#Data", document);
cmd.Connection = con;
cmd.ExecuteNonQuery();
con.Close();
// BindGridviewData();
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "javascript:alert('feedback recieved successfully')", true);
}
}
}
radiolist1.SelectedIndex = -1;
infodesc.Text = "";
RadioButtonList1.SelectedIndex = -1;
portdesc.Text = "";
msg.Text = "";
Rating1.CurrentRating = 0;
Rating2.CurrentRating = 0;
Rating3.CurrentRating = 0;
}
You cannot.
Proof:
http://www.telerik.com/forums/using-both-ajaxtoolkit-scriptmanager-and-telerikscriptmanager
An answer from Telerik team says,
"Using both script mangers (RadScriptManager and ToolkitScriptManager) is not supported since you could have only one script manager control on the page. In such cases it's appropriate to use the RadScriptManager and manually register the scripts needed by the AjaxToolKit."

Having Issues with using VISIBLE. My Javascript doesnt seem to be handling the event when the check box is clicked

All of my hidden fields have ID's. And in my JavaScript in trying to set the visible from false to true on the payment selection. The Cash payment should just display the address to be sent to. The credit card payment comes up with text boxes and labels in order to process the payment online. But when I run the script the wont appear with the checkbox selection. I assigned an onClick event and still doesnt work. Any suggestions?
<%# Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ShoppingCart.aspx.cs" Inherits="ShoppingCart" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<head>
<script type="text/javascript">
function paymentFunction() {
if (document.getElementById("rbCash").checked) {
document.getElementById("lbCash").visible = true;
document.getElementById("lbCash2").visible = true;
document.getElementById("lbCash3").visible = true;
document.getElementById("lbCash4").visible = true;
}
else
{
if(document.getElementById("rbCreditCard").checked)
{
document.getElementById("lbCard").visible = true;
document.getElementById("lbCardNum").visible = true;
document.getElementById("lbCVV").visible = true;
document.getElementById("lbexp").visible = true;
document.getElementById("ddlCard").visible = true;
document.getElementById("tbCnum").visible = true;
document.getElementById("tbcvvnum").visible = true;
document.getElementById("tbexp").visible = true;
}
}
}
</script>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
width: 100%;
}
.style3
{
width: 130px;
}
</style>
</head>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<table class="style2">
<tr>
<td class="style3">
Payment Type:</td>
<td>
<asp:CheckBox ID="rbCash" runat="server" onClick="paymentFunction()" Text="Cash" ClientIDMode="Static"/>
<asp:CheckBox ID="rbCreditCard" runat="server" onClick="paymentFunction()" Text="Credit Card" />
</td>
</tr>
<tr>
<td class="style3">
</td>
<td>
<asp:Label ID="lbCash" runat="server" ForeColor="Black"
Text="Please Send Payment To:" Visible="False" ClientIDMode="Static"></asp:Label>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td>
<asp:Label ID="lbCash2" runat="server" ForeColor="Black"
Text="Wild Style Shoes" Visible="False" ClientIDMode="Static"></asp:Label>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td>
<asp:Label ID="lbCash3" runat="server" ForeColor="Black"
Text="1808 West Avenue" Visible="False" ClientIDMode="Static"></asp:Label>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td>
<asp:Label ID="lbCash4" runat="server" ForeColor="Black"
Text="Chicago, IL 88947" Visible="False" ClientIDMode="Static"></asp:Label>
</td>
</tr>
<tr>
<td class="style3">
<asp:Label ID="lbcard" runat="server" Text="Card Type" Visible="False"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlCard" runat="server" Visible="False">
<asp:ListItem>Select A Card</asp:ListItem>
<asp:ListItem>Visa</asp:ListItem>
<asp:ListItem>Discover</asp:ListItem>
<asp:ListItem>MasterCard</asp:ListItem>
<asp:ListItem>American Express</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style3">
<asp:Label ID="lbcardnum" runat="server" Text="Card Number:" Visible="False"></asp:Label>
</td>
<td>
<asp:TextBox ID="tbCnum" runat="server" Visible="False" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
<asp:Label ID="lbCVV" runat="server" Text="CVV Number" Visible="False"></asp:Label>
</td>
<td>
<asp:TextBox ID="tbcvvnum" runat="server" Visible="False" Width="58px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
<asp:Label ID="lbexp" runat="server" Text="Expiration Date" Visible="False"></asp:Label>
</td>
<td>
<asp:TextBox ID="tbexp" runat="server" Visible="False"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td>
<asp:Button ID="Button1" runat="server" Text="Submit Payment" Visible="False" />
</td>
</tr>
</table>
<p>
</p>
<p>
</p>
<p>
Thank You For Shopping With Us:<br />
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
</asp:Content>
If you set Visible = false on the server side like you are doing, then the server will not render the control.
You probably want to do the following:
<asp:Label ID="lbCash" runat="server" ForeColor="Black"
Text="Please Send Payment To:" style="visibility:hidden" ClientIDMode="Static"></asp:Label>
Then in the javascript do something like this:
document.getElementById('lbCash').style.visibility = 'visible';

Setting selected value of RadioButtonList does not work as expected

I have a div, which is shown or hidden on the basis of some condition. In that Div I have some code as below
<div id="addPopUp" runat="server" style="padding: 30px; height: auto; width: 450px;
overflow: hidden; display: none; background-color: White; border: 1px solid black;">
<table width="500px;">
<tr>
<td valign="top" align="left" style="width: 27%;">
<input type="hidden" runat="server" id="hfLevel" />
<input type="hidden" runat="server" id="hfLevel1Id" />
<input type="hidden" runat="server" id="hfLevel2Id" />
<input type="hidden" runat="server" id="hfLevel3Id" />
</td>
<td style="width: 80%;">
</td>
</tr>
<tr>
<td style="width: 20%;" align="left" class="topics">
</td>
<td style="width: 80%;">
<asp:RadioButtonList ID="rbtnMode" runat="server" RepeatDirection="Horizontal" CssClass="mylist"
AutoPostBack="true" OnSelectedIndexChanged="rtbnMode_SelectedIndexChanged">
<asp:ListItem Selected="True" Value="Add">Add Link</asp:ListItem>
<asp:ListItem Value="Edit">Edit Link</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td style="width: 20%;" align="left" class="topics">
<strong>Link Name :</strong>
</td>
<td style="width: 80%;">
<asp:TextBox ID="txtLinkName" CssClass="txtbox" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 20%;" class="topics">
<strong>Url :</strong>
</td>
<td style="width: 80%;">
<asp:TextBox ID="txtUrl" CssClass="txtbox" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 20%;" class="topics">
<strong>Position :</strong>
</td>
<td style="width: 80%;">
<asp:TextBox ID="txtPosition" CssClass="txtbox" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 20%;" class="topics">
<strong>Show on same page :</strong>
</td>
<td style="width: 80%;">
<asp:CheckBox ID="chkSamePage" runat="server" Checked="true" />
</td>
</tr>
<tr>
<td>
</td>
<td class="topics" align="left">
<asp:Button ID="btnSave" runat="server" Text="Save" CssClass="sfCustomButton" OnClick="btnSave_Click" />
<asp:Button ID="btnHide" runat="server" Text="Hide Link" CssClass="sfCustomButton"
Visible="false" />
<input type="button" id="btnCancel" value="Cancel" class="sfCustomButton" onclick="hide()" />
</td>
</tr>
</table>
</div>
out of which Main Code comes here
<asp:RadioButtonList ID="rbtnMode" runat="server" RepeatDirection="Horizontal" CssClass="mylist"
AutoPostBack="true" OnSelectedIndexChanged="rtbnMode_SelectedIndexChanged">
<asp:ListItem Selected="True" Value="Add">Add Link</asp:ListItem>
<asp:ListItem Value="Edit">Edit Link</asp:ListItem>
</asp:RadioButtonList>
Here is some Javascript code:
function showPopUp(Level, Level1Id, Level2Id, Level3Id, id) {
var radAddEdit = document.getElementById('<%=rbtnMode.ClientID %>');
var radio = radAddEdit.getElementsByTagName("input");
for (var i = 0; i < radio.length; i++) {
if (radio[i].value == 'Add') {
radio[i].checked = true;
}
}
document.getElementById("txtLinkName").value = '';
document.getElementById("txtUrl").value = '';
document.getElementById("txtPosition").value = '';
document.getElementById("chkSamePage").checked = true;
document.getElementById("hfLevel").value = Level;
document.getElementById("hfLevel1Id").value = Level1Id;
document.getElementById("hfLevel2Id").value = Level2Id;
document.getElementById("hfLevel3Id").value = Level3Id;
document.getElementById("hfEditableId").value = id;
Popup.showModal('addPopUp', null, null, { 'screenColor': '#cccccc', 'screenOpacity': .6 });
}
function hide() {
Popup.hide('addPopUp');
}
// function BindEvents() {
$(document).ready(function () {
var hf = document.getElementById("hfShow");
if (hf.value == "1") {
Popup.showModal('addPopUp', null, null, { 'screenColor': '#cccccc', 'screenOpacity': .6 });
}
});
Function ShowPopUp is called on a link to show Div and resetting it values.
Hide is called from btnCalcel to hide Div.
document.ready() is called to show Div on some condition.
Code Behind
protected void rtbnMode_SelectedIndexChanged(Object sender, EventArgs e)
{
if (rbtnMode.SelectedValue == "Edit")
{
CatalystEntities context = new CatalystEntities();
btnHide.Visible = true;
btnSave.Visible = false;
hfShow.Value = "1";
string editValue = hfEditableId.Value;
string levelNumber = editValue.Substring(0, 6);
long id = Convert.ToInt64(editValue.Substring(6));
if (levelNumber.Contains("1"))
{
var linkInfo = context.Navigation_level1.
Where(i => i.LinkID == id)
.Select(i => new
{
i.LinkName,
i.Position,
i.Url
}).FirstOrDefault();
txtLinkName.Text = linkInfo.LinkName;
txtPosition.Text = linkInfo.Position.ToString();
txtUrl.Text = linkInfo.Url;
}
}
else
{
btnSave.Visible = true;
btnHide.Visible = false;
hfShow.Value = "1";
txtLinkName.Text = String.Empty;
txtPosition.Text = String.Empty;
txtUrl.Text = String.Empty;
}
}
PROBLEM
when I open div, go to Edit radio, it works fine. But when I click on btnHide (Remember, current selection is EDIT radio button) and click on other link. ShowPopUp() get called and it resets all controls, BUT when I click on EDIT Radio it do not postback, I click on ADD Radio, it does, Now if I click on EDIT, it does.
Means, if popup is hidden with selected value Edit it doesnot postback for first time when I select Edit radio.
Please ask me if its unclear.
Thanks
You might want to consider setting the AutoPostBack property of the control to false through the properties window or C#.
There are already post like yours, here is one with the same issue.
Radiobuttonlist event not always firing
The reason for the difference in actual vs. expected behavior is most likely you have not wrapped your div that has the ID "addPopUp" in an update panel. You can view an example of that below with example panel ID's. Alternativly you could also wrap just your radio button list with an update panel and not include the other controls in the update panel.
Read the documentation on update panels from microsoft here.
<asp:UpdatePanel ID="addPopUpUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="addPopUpPanel" runat="server">
<div id="addPopUp" runat="server" style="...">
<!-- addPopUp contents -->
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>

Returning multiple rows in asp:Table from SQL DataSet

Below is a section of my site where the data is being loaded by a sql query in the code behind, which is listed below as well... My question is how can I duplicate the second < tr > in the < table > if there are more than one record returned in the code behind query... Any pointers or tips are appreciated...
--.aspx Table
`
<h2>Rebate Measures</h2>
<asp:Textbox ID="ProjectID" runat="server"></asp:Textbox>
<table border="1">
<tr style="background-color: beige">
<th>Delete</th>
<th>Packet #</th>
<th>EEC Ref #</th>
<th class="auto-style1">PTR Ref #</th>
<th>Residential Measure</th>
<th>PTCS</th>
<th>PTCS Ducts</th>
<th>PTCS Comm</th>
<th>Bus Bar KWh</th>
<th>Saved KWh</th>
<th>Msr Life</th>
<th>BPA Credit Rate</th>
<th>BPAtoFPUD Reimburse</th>
<th># of Units</th>
<th>Unit Type</th>
<th>Funding Source</th>
<th>Bid Cost</th>
<th>Customer Rebate</th>
</tr>
<tr style="background-color:#E0E0E0">
<td>
<asp:ImageButton Style="float:none; width: 20px; padding: 0; display: inline" ToolTip="Delete" OnClick="Delete_Click" ID="ImageButton1" ImageUrl="Images/DeletePage.gif" runat="server"></asp:ImageButton>
</td>
<td>
<asp:DropDownList ID="DropDownList1" CssClass="ddl" Width="60px" OnTextChanged="PacketNum_TextChanged" AutoPostBack="true" runat="server"></asp:DropDownList>
</td>
<td>
<asp:DropDownList CssClass="ddl" ID="DropDownList2" Width="115px" OnTextChanged="EECNum_TextChanged" AutoPostBack="true" runat="server"></asp:DropDownList>
</td>
<td class="auto-style1">
<asp:TextBox ID="TextBox1" Width="100px" runat="server"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="TextBox2" Width="350px" runat="server" Wrap="true" ></asp:TextBox>
</td>
<td>
<asp:TextBox ID="TextBox3" MaxLength="3" Columns="1" runat="server" Width="34px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="TextBox4" runat="server" Width="61px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="TextBox5" runat="server" Width="59px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="TextBox6" runat="server" Width="45px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="TextBox7" runat="server" Width="45px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="TextBox8" runat="server" Width="30px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="TextBox9" ReadOnly="true" runat="server" Width="78px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="TextBox10" BackColor="LightPink" runat="server" Width="128px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="TextBox11" TextMode="Number" OnTextChanged="PacketNum_TextChanged" AutoPostBack="true" runat="server" Width="40px"></asp:TextBox>
</td>
<td>
<asp:DropDownList ID="DropDownList3" CssClass="ddl" runat="server">
<asp:ListItem Text="EA" Value="EA"></asp:ListItem>
<asp:ListItem Text="SqFt" Value="SqFt"></asp:ListItem>
<asp:ListItem Text="LnFt" Value="LnFt"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="DropDownList4" CssClass="ddl" OnTextChanged="PacketNum_TextChanged" AutoPostBack="true" runat="server">
<asp:ListItem Text="EEI" Value="EEI" Selected="True"></asp:ListItem>
<asp:ListItem Text="Self" Value="Self"></asp:ListItem>
<asp:ListItem Text="Delta" Value="Delta"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="TextBox12" runat="server" Width="63px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="TextBox13" runat="server" Width="93px"></asp:TextBox>
</td>
</tr>
</table>
`
--Code Behind Query
string CS = ConfigurationManager.ConnectionStrings["CARD"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
String sql = "Select * from tbl_Measures_New1 Where Project_ID = #ProjectID and Project_ID like 'R%'";
SqlDataAdapter Msrda = new SqlDataAdapter(sql, con);
Msrda.SelectCommand.Parameters.AddWithValue("#ProjectID", ProjectID.Text);
DataSet Msrds = new DataSet();
Msrda.Fill(Msrds, "Msr");
ViewState["SQL"] = sql;
ViewState["Msr"] = Msrds;
if (Msrds.Tables["Msr"].Rows.Count > 0)
{
DataRow Msrdr = Msrds.Tables["Msr"].Rows[0];
AccountSelect.Text = Msrdr["Account_Num"].ToString();
OccCode.Text = Msrdr["Occ_Code"].ToString();
Measure.Text = Msrdr["Measure"].ToString();
Funding.SelectedValue = Msrdr["Funding_Source"].ToString();
PacketNum.Text = Msrdr["FPUD_Packet_No"].ToString();
EECNum.Text = Msrdr["EEC_Ref_Num"].ToString();
PTRNum1.Text = Msrdr["BPA_Ref_Num"].ToString();
VendorList.SelectedValue = Msrdr["Vendor_ID"].ToString();
SecVendorList.SelectedValue = Msrdr["Secondary_Vendor_ID"].ToString();
BidCost.Text = "$" + Msrdr["Measure_Cost"].ToString().Replace(".0000", ".00");
CustomerRebate.Text = "$" + Msrdr["Customer_Rebate"].ToString().Replace(".0000", ".00");
SavedKWh.Text = Msrdr["Saved_Kwh"].ToString();
Busbar.Text = Msrdr["BusBar_Kwh"].ToString();
BPACredit.Text = "$" + Msrdr["BPA_Credit"].ToString().Replace(".0000", ".00");
BPAReimburse.Text = "$" + Msrdr["BPA-FPUD_Reimburse"].ToString().Replace(".0000", ".00");
Units.Text = Msrdr["Measure_Units"].ToString();
if (Units.Text != "")
{
Units.Text = Msrdr["Measure_Units"].ToString();
}
else
{
Units.Text = "1";
}
UnitType.SelectedValue = Msrdr["Unit_Type"].ToString();
MsrLife.Text = Msrdr["Measure_Life"].ToString();
PTCS.Text = Msrdr["PTCS"].ToString();
Ducts.Text = Msrdr["PTCS_Ducts"].ToString();
Comm.Text = Msrdr["PTCS_Comm"].ToString();
}
There are a few ways to do this. Look into the Repeater control if you want to use a table like this, or look into using a GridView and binding your result set to that. (It is possible to have a dropdowns and textboxes inside of a GridView.)
Also, make sure your code validates ProjectID.Text to avoid any potential SQL injection issues!

Asynchronously extend multiple CollapsiblePanels

I have a webpage that is setup like so:
There is a ListView that has an item for each record in one of our SQL tables. Each of these items has a CollapsiblePanel in it that can be expanded to show more detail about the given record.
My Issue:
When I expand one panel and then wait for it to complete...everything is okay. However, if I try to expand multiple of those collapsiblepanels at once (meaning before the first panel is completely expanded)...only the last panel expands showing its data.
My Question:
Is it possible to have each of these panels expand asynchronously? Seems silly that I have to wait for one panel to extend before I can extend another.
My aspx:
I modified this aspx a little bit by removing unneeded code to make it less confusing.
<asp:UpdatePanel ID="UpdPnlBGList" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<div class="content-box">
<asp:Panel ID="pnlBGResult" runat="server">
<asp:ListView ID="lvSummary" runat="server" ItemPlaceholderID="placeholderBGList"
OnItemDataBound="lvSummary_ItemDataBound" OnItemCommand="lvSummary_ItemCommand">
<LayoutTemplate>
<table runat="server" id="tblList" cellpadding="0" cellspacing="0" border="0" style="table-layout: fixed;">
<tr id="placeholderBGList" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td>
<asp:UpdatePanel ID="UpdBgItemTemplate" runat="server" ChildrenAsTriggers="true"
UpdateMode="Conditional">
<ContentTemplate>
<div class="bgList">
<asp:Panel ID="pnlSummary" runat="server">
<table id="tblBgList" runat="server" cellpadding="0" cellspacing="0" border="0" style="border-collapse: collapse;
border-spacing: 0px;">
<tr>
<td class="imageColumn">
<asp:ImageButton ID="imgCollapsible" CssClass="first" ImageUrl="~/Images/branding/plus.gif"
runat="server" CommandName="ExpandCollapse" Style="cursor: pointer; padding-right: 5px;" />
</td>
<td width="600px">
<asp:Label ID="lblBGName" runat="server" Text='<%# Eval("BGName")%>' CssClass="bgName"></asp:Label>
<asp:Label ID="lblDatePosted" runat="server" CssClass="datePosted"></asp:Label>
</td>
<td colspan="2">
<div style="float: right;">
<asp:Label ID="lblAccountNumber" runat="server" CssClass="accountReview"></asp:Label>
<asp:Label ID="lblAccountNumberText" runat="server" CssClass="accountReview"></asp:Label>
</div>
</td>
</tr>
<tr>
<td>
</td>
<td width="600px">
<asp:Label ID="lblBillToAddress" runat="server" Text='<%# Eval("BillToAddress")%>'
CssClass="billToAddress" Style="font-weight: bold;"></asp:Label>
</td>
<td>
<div style="float: right;">
<asp:ImageButton ID="imgViewAuthLetter" ImageUrl="~/Images/branding/document.jpeg"
CssClass="first" runat="server" OnClick="imgViewAuthLetter_Click" />
<asp:LinkButton ID="lnkAuthorizationLetter" runat="server" Text="View authorization letter"
class="link_button" OnClick="lnkAuthorizationLetter_Click" OnClientClick="dirtySuppress();"
OnPreRender="addTrigger_PreRender" />
</div>
</td>
<td width="70px" style="float: right;">
<div style="float: right;">
<asp:HyperLink ID="lnkExportImage" runat="server" ImageUrl="/Images/branding/export.jpg"
CssClass="hiperlinkExport" OnClick="dirtySuppress();" />
<asp:HyperLink ID="lnkExportText" runat="server" Text="Export" CssClass="hiperlinkExport"
OnClick="dirtySuppress(); precheckURL(this.href); return false;" />
</div>
</td>
</tr>
<tr>
<td colspan="4" style="padding: 0px;">
<asp:Panel Style="margin-left: 50px;" ID="pnlDetails" runat="server">
<of:AccountNumberListControl ID="accountNumberList" runat="server"></of:AccountNumberListControl>
</asp:Panel>
<cc1:CollapsiblePanelExtender ID="cpe" runat="Server" TargetControlID="pnlDetails"
CollapsedSize="0" Collapsed="True" ExpandControlID="imgCollapsible" CollapseControlID="imgCollapsible"
AutoCollapse="False" AutoExpand="False" ScrollContents="false" ImageControlID="imgCollapsible"
ExpandedImage="~/Images/branding/minus.gif" CollapsedImage="~/Images/branding/plus.gif"
ExpandDirection="Vertical" />
</td>
</tr>
<tr>
<td>
</td>
<td colspan="3" style="padding: 0px;">
<div class="itemSeperator" id="divItemSeperator" runat="server">
</div>
</td>
</tr>
</table>
</asp:Panel>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<asp:HiddenField ID="hdfAccountNumberListControlID" runat="server" Value="" />
<asp:HiddenField ID="hdfAccountNumerID" runat="server" Value="" />
</asp:Panel>
</div>
<of:CustomerSetupExportPopInControl ID="customerSetupExportPopIn" runat="server" />
</ContentTemplate>
My codebehind:
This is the code that is executed when you expand the panel. There are several controls that is populated.
private void ExpandBillingGroup(ListViewDataItem item)
{
Label accountNumberLabel;
Label accountNumberText;
HtmlControl itemSeperator;
AccountNumberListControl accountNumberList;
// set properties for fedex account number label and text.
accountNumberLabel = (Label)item.FindControl("lblAccountNumber");
accountNumberLabel.Text = "FedEx account number: ";
accountNumberLabel.CssClass = "fedExAccountNumberLabel";
accountNumberText = (Label)item.FindControl("lblAccountNumberText");
accountNumberText.Text = lvSummary.DataKeys[item.DisplayIndex].Values["FedExAccountNumber"].ToString();
accountNumberText.CssClass = "fedExAccountNumberText";
//set the properties for Export
var lnkExportImage = (HyperLink)item.FindControl("lnkExportImage");
lnkExportImage.Visible = true;
var lnkExportText = (HyperLink)item.FindControl("lnkExportText");
lnkExportText.Visible = true;
//When expanded populate Customer Setup Export control
customerSetupExportPopIn.BillingGroupID = lvSummary.DataKeys[item.DisplayIndex].Values["BillingGroupID"].ToString();
//When expanded populate AccountNumberlistControl
accountNumberList = (AccountNumberListControl)item.FindControl("accountNumberList");
if (accountNumberList != null)
{
//since we make the AccountNumberListControl not visible on collapse we have to make it visible when we expand
accountNumberList.Visible = true;
//Set the properties
accountNumberList.BillingGroupID = lvSummary.DataKeys[item.DisplayIndex].Values["BillingGroupID"].ToString();
accountNumberList.FedExAccountNumber = lvSummary.DataKeys[item.DisplayIndex].Values["FedExAccountNumber"].ToString();
accountNumberList.BillingGroupName = ((Label)lvSummary.Items[item.DisplayIndex].FindControl("lblBGName")).Text;
accountNumberList.BillToAddress = ((Label)lvSummary.Items[item.DisplayIndex].FindControl("lblBillToAddress")).Text;
accountNumberList.FirstItemNeedsToExpand = BillingGroupIsResolved;
accountNumberList.GetListOfAccountNumbers(lvSummary.DataKeys[item.DisplayIndex].Values["BillingGroupID"].ToString(), VendorID);
}
//set the properties for itemSepeartor
itemSeperator = (HtmlControl)item.FindControl("divItemSeperator");
itemSeperator.Attributes.Add("class", "itemSeperatorExpanded");
UpdatePanel upd = (UpdatePanel)item.FindControl("UpdBgItemTemplate");
upd.Update();
}
Thanks,
Holt
EDIT: Fixed grammar and title issues

Categories