DataSource And Code Behind - c#

how can i use object of data source that declared in aspx files in code behind ?
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetEntryByID"
TypeName="Entry">
<SelectParameters>
<asp:QueryStringParameter DbType="Guid" Name="id" QueryStringField="ID" />
</SelectParameters>
</asp:ObjectDataSource>
my data source has an object named "ID" i am using Eval("ID") in asp file , how can i get it in code behind without calling select method and using that data source ?
more code :
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="ObjectDataSource1" BorderStyle="None">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<p style="vertical-align: middle; margin: 8px; background-color: #af9b9b; width: 475px;
line-height: 30px; padding-left: 20px; padding-right: 20px;">
<span style="float: left;">View Count :
<%# Eval("View") %>
</span>
<asp:HyperLink ID="HyperLink2" NavigateUrl='<%# Eval("ID","~/ShowStory.aspx?ID={0}") %>'
runat="server"><%# Eval("Title") %></asp:HyperLink></p>
<p style="padding: 10px; padding-top: 0;">
<%# Eval("Text") %></p>
<p style="vertical-align: middle; margin: 8px; background-color: #af9b9b; width: 475px;
line-height: 30px; padding-left: 20px; padding-right: 20px;">
Author : <asp:Label ID="lblUser" runat="server" Visible=false Text=""><%# Eval("UserID") %></asp:Label><asp:Label
ID="lblUser2" runat="server" Text="Label"></asp:Label></p>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
now i want to use membership.GetUser("ID").UserName to get user name via user provider key . and show it in lblUser how ?

membership.GetUser(ObjectDataSource1.ID).UserName would get you the user name of the user matching the ID property, if I'm understanding what you're asking.
To assign it to the asp:Label object would simply be
lblUser.Text = membership.GetUser(ObjectDataSource1.ID).UserName

Related

How to get Link button generated text inside repeater control

I am creating a social network site, I cant seem to get the "LinkEmail" in the code behind, I need this to function as I then use it to post to the database.
The LinkEmail is being dynamically generated in the first repeater, I need a way to grab that value.
at the moment I am getting this error in the browser:
Compiler Error Message: CS0103: The name 'LinkEmail' does not exist in the current context
this is aspx code
<asp:Repeater runat="server" ID="Repeater1">
<ItemTemplate>
<div style="border-top: thin none #91ADDD; border-bottom: thin none #91ADDD; padding: 10px; width: 548px; margin-top: 10px; right: 10px; left: 10px; border-left-width: thin; margin-left: 15px; background-color: #F6F6F6; border-left-color: #91ADDD; border-right-color: #91ADDD;">
<br />
<div style="width: 58px; height: 40px">
<asp:Image ID="Image2" runat="server" Height="59px" ImageAlign="Top" ImageUrl="~/Profile/Image/Default.png" Width="55px" />
</div>
<div style="width: 307px; margin-left: 65px; margin-top: -60px">
<asp:Label ID="Label6" runat="server" Font-Bold="True" Font-Names="Arial" ForeColor="#3b5998"><%#Eval("YourName") %> </asp:Label>
</div>
<div id="status" style=" width: 461px; margin-left: 78px; margin-top: 11px;"> <asp:Label ID="Label7" runat="server" Font-Italic="False" ForeColor="Black" Font-Size="Medium"><%#Eval("Birthday") %> </asp:Label>
<asp:LinkButton ID="LinkEmail" runat="server" OnClick="lbl_Click"><%#Eval("Email") %></asp:LinkButton>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</div>
</ItemTemplate>
Actually i want to get Link button generated text as a session like this photo when someone click this link. could you give me a suitable codes for this.
According to this photo amilamunasinha#gmail.com must be LinkEmail.Text ,,, I want like this
The first thing you have to do, once your Repeater control is on your Web page, is register for the ItemCommand event. I prefer to do this within the OnInit event of the page instead of placing it as an attribute of the asp:Repeater tag.
In .cs file:
override protected void OnInit(EventArgs e)
{
base.OnInit(e);
Repeater1.ItemCommand += new RepeaterCommandEventHandler(Repeater1_ItemCommand);
}
private void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
switch (e.CommandName)
{
case "mail":
string emailId = e.CommandArgument.ToString();
break;
}
}
In aspx:
<asp:LinkButton ID="LinkEmail" runat="server" CommandName="mail" CommandArgument='<%# Eval("Email") %>'><%#Eval("Email") %></asp:LinkButton>

Changing message displays to bottom to top

Hi I am doing a social network service using asp.net/c#, I have little problems with message sending. Message are flowed top to bottom. Like this
But I want to display messages bottom to top Like facebook..
I am displaying messages using repeater control.
repeater control code
<asp:Repeater runat="server" ID="Repeater1">
<ItemTemplate>
<div style="border-top: thin none #BBCEB3; border-bottom: thin none #BBCEB3; padding: 10px; width: 548px; margin-top: 10px; right: 10px; left: 10px; border-left-width: thin; margin-left: 15px; background-color: #e9eaee; border-left-color: #BBCEB3; border-right-color: #BBCEB3;">
<br />
<div style="width: 58px; height: 40px">
<asp:Image ID="Image2" runat="server" Height="59px" ImageAlign="Top" ImageUrl="~/Profile/Image/Default.png" Width="55px" />
</div>
<div style="width: 307px; margin-left: 65px; margin-top: -60px">
<asp:Label ID="Label6" runat="server" Font-Bold="True" Font-Names="Arial" ForeColor="#000066"><%#Eval("SenderID") %> </asp:Label>
</div>
<div id="status" style=" width: 461px; margin-left: 78px; margin-top: 11px;"> <asp:Label ID="Label7" runat="server" Font-Italic="False" ForeColor="Black" Font-Size="Medium"><%#Eval("Messages") %> </asp:Label>
</div>
<div style="margin-left: 350px">
<asp:Label ID="Label11" runat="server" Text="Posted on: " Font-Size="Small"><%#Eval("Time") %> </asp:Label>
</div>
</div>
</ItemTemplate>
Textbox code
<asp:TextBox ID="Message" runat="server" OnTextChanged="TextBox3_TextChanged" style="margin-left: 12px; text-align: left;" TextMode="MultiLine" Width="564px" Height="100px"></asp:TextBox>
The order of Items in the repeater will be the same as in DataSource, so just Order it by Time descending before bind.

Page load first time:Page index in gridView not working

I have two gridView: grvHeadline and gdvNotification, gdvNotification is load data by selected item of grvHeadline .
When page load: data of gdvNotification is load by first item of grvHeadline.
My problem is:
The page load is first: if gdvNotification has paging (1,2,3,...), when i click paging in gdvNotification, it not run. Page is reload but page index is 0.
When i select other item in grvHeadline and reselect first item, then click paging in gdvNotification, it run, page index was changed.
I was debug: When the page is load first time: I click to page index in gdvNotification then pageload() was called with IsPostBack=True, but not call to event gdvNotification_PageIndexChanging of gdvNotification.
Here is my code:
protected void gdvNotification_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
logger.Debug("Gridview Headline page index changing .");
gdvNotification.PageIndex = e.NewPageIndex;
HeadlineSelected(hdfNotificationIdSelected.Value, e.NewPageIndex);
//gdvNotification.DataBind();
lbPageIndex.Text = (e.NewPageIndex + 1).ToString(CultureInfo.InvariantCulture);
}
And
private void HeadlineSelected(string notificationIdSelected, int index)
{
logger.Debug("Head line selected");
GetDataFromSessionAndCache();
IList<InformationEntity> infoNotificationList = new List<InformationEntity>();
if (string.IsNullOrEmpty(notificationIdSelected))
{
//Clear
IList<InformationEntity> data = new List<InformationEntity>()
{
new InformationEntity()
{
AuthorName = string.Empty,
Contents = string.Empty,
BulletinDateFrom = null,
BulletinDateTo = null,
Id = string.Empty,
Subject = string.Empty,
}
};
gdvNotification.DataSource = data;
gdvNotification.DataBind();
pnPageIndex.Visible = false;
btnEditNotification.Enabled = false;
}
else
{
infoNotificationList = MasterDataHelper.GetInformationByHighOrderId(notificationIdSelected);
logger.Debug("Notification list not null");
if (infoNotificationList != null)
{
if (infoNotificationList.Count == 0)
{
pnPageIndex.Visible = false;
hdfNotificationId.Value = string.Empty;
btnEditNotification.Enabled = false;
}
else
{
if (infoNotificationList.Count == 1)
{
fakepanel.Visible = true;
}
else
{
fakepanel.Visible = false;
}
if (base.IsPermission(PERMISSION_INFORMATION_FOLLOWUP))
{
btnEditNotification.Enabled = true;
}
pnPageIndex.Visible = true;
gdvNotification.PageIndex = index;
hdfNotificationId.Value = infoNotificationList[index].Id;
gdvNotification.DataSource = infoNotificationList;
gdvNotification.DataBind();
}
logger.Debug("Set value for label total page");
lblTotalPage.Text = gdvNotification.PageCount.ToString(CultureInfo.InvariantCulture);
lbPageIndex.Text = gdvNotification.PageCount == 0
? gdvNotification.PageCount.ToString(CultureInfo.InvariantCulture)
: (gdvNotification.PageIndex + 1).ToString(CultureInfo.InvariantCulture);
lbTotal.Text = infoNotificationList.Count().ToString(CultureInfo.InvariantCulture);
}
}
}
Update code in view *.aspx.
<table style="padding-top: 25px; padding-bottom: 25px; table-layout: fixed" width="100%">
<tr>
<td style="width: 49%" class="Top">
<table class="Master" style="width: 100%; height: 35px; border-spacing: 2px 0px">
<tr style="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">
<td class="BasicValue" style="width: 100%; padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">
<asp:Panel ID="Panel2" runat="server" DefaultButton="btnSearch">
<asp:TextBox ID="txtFuzzySearch" runat="server" Style="width: 76%; height: 25px; text-align: left;
float: left; border-style: double; border-color: Gray;" />
<asp:Label ID="label" runat="server" Text="※あいまい検索" Width="20%" Style="text-align: center;
vertical-align: middle; margin-top: 5px;" />
<asp:Button ID="btnSearch" runat="server" Text="Button" Style="display: none" OnClick="btnSearch_Click" />
</asp:Panel>
</td>
</tr>
</table>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="panelContainer" runat="server" Width="100%" Height="582px" Style="margin-top: 0px;overflow-y: auto">
<asp:HiddenField ID="hdfNotificationIdSelected" runat="server" Value="" />
<asp:GridView ID="grvHeadline" runat="server" AutoGenerateColumns="False" Style="width: 100%"
BorderWidth="0px" CellSpacing="2" CellPadding="10" GridLines="None" ShowHeader="false"
OnSelectedIndexChanged="grvHeadline_SelectedIndexChanged" OnRowDataBound="grvHeadline_RowDataBound">
<HeaderStyle CssClass="BasicColumnTitle" />
<AlternatingRowStyle CssClass="RowStyleEven" />
<RowStyle CssClass="RowStyleOdd" />
<SelectedRowStyle CssClass="RowStyleHi heallineSelected" />
<Columns>
<asp:TemplateField>
<HeaderStyle Width="10%" />
<ItemStyle Width="80%" />
<ItemTemplate>
<table style="border-spacing: 0px">
<tr>
<td>
<asp:Image ID="Image6" runat="server" ImageAlign="Left" Style="display: none" ImageUrl="../img/triangle-on.png" />
<asp:Image ID="Image1" runat="server" ImageAlign="Left" Style="display: none" ImageUrl="../img/triangle-off.png" />
<asp:Image ID="Image4" runat="server" Visible='<% #int.Parse(Eval("ThreadQty").ToString()) < 2%>'
ImageAlign="Left" ImageUrl="../img/Doc1.png" />
<asp:Image ID="Image5" runat="server" Visible='<% #int.Parse(Eval("ThreadQty").ToString())>=2%>'
ImageAlign="Left" ImageUrl="../img/Doc2.png" />
</td>
<td>
<asp:Label CssClass="bold" Style="resize: none; width: 100%; margin-left: 5px; vertical-align: bottom;
text-align: justify" ID="txt1" Text='<%#DevideString(HttpUtility.HtmlEncode(Eval("Subject")), 35) %>' runat="server">
</asp:Label><br />
<asp:Label CssClass="bold" Style="resize: none; margin-left: 5px; vertical-align: bottom; text-align: justify;"
ID="txt2" Text='<%#DevideString(HttpUtility.HtmlEncode(Eval("AuthorName")), 35) %>' runat="server" />
</td>
</tr>
</table>
<asp:HiddenField ID="hdfSelectedId" runat="server" Value='<% #Eval("Id")%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderStyle Width="3%" />
<ItemStyle Width="20%" VerticalAlign="Top" CssClass="position" />
<ItemTemplate>
<table style="border-spacing: 0px; height: 100%;" width="100%">
<tr>
<td class="Top Left" style="height: auto;">
<asp:Image ID="Image3" runat="server" CssClass="Top Left" Visible='<%# ShowImgUpScreen(DateTime.Parse(Eval("BulletinDateFrom").ToString()),Eval("ThreadQty").ToString()) %>'
ImageAlign="Left" Style="vertical-align: top;" ImageUrl="~/img/Up1.png" />
<asp:Image ID="Image7" runat="server" CssClass="Top Left" Visible='<%# ShowImgNewScreen(DateTime.Parse(Eval("BulletinDateFrom").ToString()),Eval("ThreadQty").ToString()) %>'
ImageAlign="Left" Style="vertical-align: top;" ImageUrl="~/img/New2.png" />
</td>
</tr>
</table>
<asp:Label ID="Label4" runat="server" CssClass="Right Bottom" Text='<%#CheckDateTime((DateTime)Eval("BulletinDateFrom"))%>'
Style="float: right; position: absolute; bottom: 3px; right: 3px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="grvHeadline" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<table class="BasicValue" style="width: 100%; margin-bottom: -58px; margin-top: 43.5px">
<tr style="padding: 0px 0px 0px 0px; margin: 100px 0px 0px 0px;">
<td class="BasicValue" style="padding: 5px 10px 5px 10px">
<asp:Button ID="btnNewHeadline" class="ButtonSchedule" runat="server" Text="ヘッドラインの新親追加"
Height="100%" Style="text-align: center; float: right; margin: 0px 5px 0px 0px;"
Width="165px" OnClick="btnNewHeadlineRegist_Click" />
</td>
</tr>
</table>
</td>
<td style="width: 1%;" class="Center">
<div class="verticalLine" style="background-color: #C5C5CA; text-align: center; height: 696px;
width: 4px; margin-left: 48%">
</div>
</td>
<td style="width: 49%; position: relative" class="Top">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:HiddenField ID="hdfNotificationId" runat="server" />
<asp:GridView ID="gdvNotification" runat="server" AutoGenerateColumns="False" Style="width: 100%;"
BorderWidth="0px" CellSpacing="0" CellPadding="0" GridLines="None" PageSize="1"
AllowPaging="True" ShowHeader="false" OnPageIndexChanging="gdvNotification_PageIndexChanging">
<HeaderStyle CssClass="BasicColumnTitle" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Panel ID="panel1" runat="server" Width="100%" Height="618" ScrollBars="Vertical">
<table style="width: 100%;">
<tbody>
<tr style="height: 40px">
<td class="BasicValue" style="vertical-align: bottom;padding-left:2em">
<div>
<asp:Label ID="lblhead" CssClass="bold" runat="server" Text='<% #Eval("Subject")%>' Style=" font-weight: bold"></asp:Label>
</div>
</td>
</tr>
<tr style="height: 40px">
<td class=" BasicValue" style="vertical-align: bottom ;padding-left: 2em;">
<div>
<asp:Label ID="Label2" runat="server" Style=" font-weight: bold" Text='<% #Eval("AuthorName")%>'></asp:Label><asp:Label
ID="Label3" runat="server" Style="float: right" Text='<%# string.Format("{0:yyyy/MM/dd hh:mm}",Eval("BulletinDateFrom"))%>'></asp:Label></div>
</td>
</tr>
<tr style="height: 40px">
<td class="BasicValue" style="vertical-align: bottom">
<div>
<asp:Label ID="lblSection" runat="server" Style="padding-left: 2em;" Text='<%# GetSectionName(Eval("Id").ToString())%>'></asp:Label>
</div>
</tr>
<tr style="height: 497px;">
<td class="BasicValue" style="text-align: left; vertical-align: top; padding-left:2em ">
<asp:Label ID="lblContent" runat="server"
Text='<% #Eval("Contents")%>'></asp:Label>
</td>
</tr>
</tbody>
</table>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Panel runat="server" ID="fakepanel" Height="30px">
</asp:Panel>
<div class="Center" style="margin-bottom: 0px; margin-top: 0cm; font-family: MS Pゴシック">
<asp:Panel ID="pnPageIndex" runat="server">
<span>Page
<asp:Label ID="lbPageIndex" runat="server" /><span>/</span><asp:Label ID="lblTotalPage"
runat="server"></asp:Label>
<span>(<asp:Label ID="lbTotal" runat="server"></asp:Label>件)</span></span>
</asp:Panel>
</div>
<table style="width: 100%;position: absolute; bottom: 0px">
<tr style="margin: 0px 0px 0px 0px;">
<td class="BasicValue" style="margin: 0px 0px 0px 0px; width: 100%; padding: 5px 10px 5px 10px">
<asp:Button ID="btnEditNotification" CssClass="ButtonSchedule" runat="server" Text="お知らせの編集"
Height="85%" Style="float: left; text-align: center; margin: 0px 10px 0px 0px; position: relative; left: 260px"
Width="158px" OnClick="btnEditNotification_Click" />
<asp:Button ID="btnUpdateNotification" CssClass="ButtonSchedule" runat="server" Text="このお知らせに追記"
Height="85%" Style="float: right; text-align: center; margin: 0px 5px 0px 0px;"
Width="158px" OnClick="btnUpdateNotification_Click" />
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="grvHeadline" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="gdvNotification" EventName="PageIndexChanging" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
</table>
Can somebody tell me what's happening?
(p/s: i'm trying to learning English, if you don't understand, please tell me.)

Prevent Modal Dialog from closing on submit when client side validation fails

I have a Submit button on the page, which upon being clicked, shows a modal popup window. This modal popup window contains a checkbox that must be checked before the OK button of the modal can be clicked:
<script language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
function cvcbCertify_ClientValidate(sender, e) {
var elem = document.getElementById('<%= cbCertify.ClientID %>');
if (elem.checked)
e.IsValid = true;
else {
$('.pnlConfirm').show(); //not working?
e.IsValid = false;
}
}
<ajaxToolkit:ConfirmButtonExtender ID="cbeResponseReferralSignOff" runat="server"
TargetControlID="ResponseLocalSignOff" DisplayModalPopupID="popConfirm">
</ajaxToolkit:ConfirmButtonExtender>
<ajaxToolkit:ModalPopupExtender runat="server" ID="popConfirm" TargetControlID="ResponseLocalSignOff"
BackgroundCssClass="modalBackground" DropShadow="true" OkControlID="btnConfirmCertify"
CancelControlID="btnCancel" PopupControlID="pnlConfirm">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel runat="server" ID="pnlConfirm" Style="display: none; background-color: White;
border: solid 1px Gray; width: 90%; height: 100%; padding: 10px" CssClass="pnlConfirm">
<asp:Panel runat="server" ID="pnlConfirm" Style="display: none; background-color: White;
border: solid 1px Gray; width: 90%; height: 100%; padding: 10px" CssClass="pnlConfirm">
popup text here
<asp:CheckBox runat="server" ID="cbCertify" Text="I Certify" CssClass="cbCertify">
</asp:CheckBox>
<br />
<asp:CustomValidator runat="server" ID="cvcbCertify" ClientValidationFunction="cvcbCertify_ClientValidate">Required.</asp:CustomValidator>
<br />
<div style="text-align: center">
<asp:Button runat="server" ID="btnConfirmCertify" Text="OK" />
<asp:Button runat="server" ID="btnCancel" Text="Cancel" />
</div>
</asp:Panel>
The problem is the modal window closes when validation fails. How do I prevent this window from closing or repoppen this window?
The only way to do this is by using an UpdatePanel. Additionally this will allow you to use AsyncPostBackTrigger with a Conditional UpdateMode with control events as well.
For example
<asp:Panel runat="server" ID="pnlConfirm" Style="display: none; background-color: White;
border: solid 1px Gray; width: 90%; height: 100%; padding: 10px" CssClass="pnlConfirm">
<asp:UpdatePanel ID="upItem" runat="server">
<ContentTemplate>
popup text here
<asp:CheckBox runat="server" ID="cbCertify" Text="I Certify" CssClass="cbCertify">
</asp:CheckBox>
<br />
<asp:CustomValidator runat="server" ID="cvcbCertify" ClientValidationFunction="cvcbCertify_ClientValidate">Required.</asp:CustomValidator>
<br />
<div style="text-align: center">
<asp:Button runat="server" ID="btnConfirmCertify" Text="OK" />
<asp:Button runat="server" ID="btnCancel" Text="Cancel" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
Solution was to get rid of the ConfirmButtonExtender and make my own validation:
function Validate_Click() {
//using asp.net checkbox so have to go this route to get bool
var checked = $('#<%= cbCertify.ClientID %>').is(':checked');
if (checked) {
$('.lblConfirmCertifyError').hide();
return true;
}
else {
$('.lblConfirmCertifyError').show();
return false;
}
}
<asp:Panel runat="server" ID="pnlConfirm" Style="display: none; background-color: White;
border: solid 1px Gray; width: 90%; height: 100%; padding: 10px">
popup text here
<asp:CheckBox runat="server" ID="cbCertify" Text="I Certify" CssClass="cbCertify">
</asp:CheckBox>
<br />
<asp:Label runat="server" ID="lblConfirmCertifyError" Text="Required." ForeColor="Red"
Style="display: none" CssClass="lblConfirmCertifyError"></asp:Label>
<br />
<div style="text-align: center">
<asp:Button runat="server" ID="btnConfirmCertify" Text="OK" CssClass="btnConfirmCertify" OnClientClick="return Validate_Click()" />
<asp:Button runat="server" ID="btnCancel" Text="Cancel" />
<asp:Button runat="server" ID="btnDummy" Text="" Style="display: none" />
</div>
</asp:Panel>

how to fire javascript on a button inside item template

when i click on the button which is inside the item template of gridview then onclientclick event should fire and then call the javascript function but my problem is that there no onclientclick event is fire in item template button.
<%# Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.dvBroker
{
display: none;
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 100%;
background-image: url(image/broker_bg.png);
background-repeat: repeat;
}
.collection_heading2
{
font-family: verdana;
font-size: 12px;
font-weight: bold;
color: #000000;
background-image: url(image/gray_bg.gif);
background-repeat: repeat-x;
height: 20px;
width: 386px;
margin-left: 30%;
margin-top: 50px;
padding: 7px 7px 0px 7px;
border: 3px solid #000000;
border-bottom: none;
text-align: center;
}
.broker_window
{
border: 3px solid #000000;
height: 250px;
overflow: auto;
width: 400px;
background-color:White;
margin-left: 30%;
border-top: none;
padding-top: 10px;
text-align: left;
}
</style>
</head>
<body>
<script type="text/javascript" language="javascript">
function Show()
{
document.getElementById("dvStage").style.display='block';
return false;
}
function Close()
{
document.getElementById("dvStage").style.display='none';
return false;
}
</script>
<form id="form1" runat="server">
<asp:ScriptManager ID="sc1" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>
<div>
<asp:Label ID="lblmsg" runat="server" ForeColor="#FF3300"></asp:Label>
<asp:LinkButton ID="lbnaddnewcharge" runat="server" OnClientClick="return Show();"
Text="Show"></asp:LinkButton>
</div>
<div>
ROLL NO:
<asp:TextBox ID="txtrollno" runat="server"></asp:TextBox>
<div>
STUDENT NAME:
<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="ADD" BorderStyle="Ridge" OnClick="btnadd_Click" /></div>
<asp:GridView ID="gvstudent" runat="server" AutoGenerateColumns="False" Width="857px"
OnRowDataBound="gvstudent_RowDataBound" OnSelectedIndexChanged="gvstudent_SelectedIndexChanged1">
<Columns>
<asp:BoundField HeaderText="ROLL NO" DataField="roll_no" />
<asp:BoundField HeaderText="NAME" DataField="name" />
<asp:BoundField HeaderText="TOTAL" DataField="total" />
<asp:BoundField HeaderText="STATUS" DataField="status" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button CommandName="Click" ID="btnclick" OnCommand="btnclick_Click" CommandArgument='<%#Eval("roll_no") %>'
OnClientClick="return Show('aspnetForm','[gvstudent]');" runat="server" Text="Click" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div id="dvstage" class="dvBroker">
<div class="collection_heading2">
<div style="float: left">
SUBJECT
</div>
<div style="float: right">
<asp:ImageButton ID="btnclose" runat="server" ImageUrl="~/image/delete.png" OnClientClick="return Close();" />
</div>
</div>
<div class="broker_window">
<asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:PopupControlExtender ID="PopupControlExtender1" runat="server" TargetControlID="gvchild"
PopupControlID="btnclick" Position="Center">
</asp:PopupControlExtender>
<asp:GridView ID="gvchild" OnRowDataBound="gvChild_RowDataBound" runat="server" AutoGenerateColumns="false"
EmptyDataText="NO Row in grid view">
<Columns>
<asp:BoundField HeaderText="Subject" DataField="subject_name" />
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="txtsubject" runat="server" Text='<%#Bind("marks") %>'></asp:TextBox></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="btnaddchild" runat="server" Text="ADD" OnClick="btnaddchild_Click" />
<asp:Button ID="btncancle" runat="server" Text="CANCLE" OnClick="btncancle_Click1" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</form>
</body>
</html>
Use a client-side framework like jQuery. Don't put all the onclick client-side events inline. It bloats your markup and it's harder to maintain. Bind the events instead, e.g. http://api.jquery.com/bind and/or http://api.jquery.com/live.
Since its ASP.NET WebForms, your HTML elements id attributes are rendered as the ClientID property of the server controls, so if that causes problems for you getting a reference to the elements to bind events to via id using a jQuery selector, use jQuery's selectors, http://api.jquery.com/category/selectors .
e.g.
$("input[id$='btnClose'").live("click", function(event) {
$("#dvStage").hide();
event.stopPropagation();
});
$("a[id$='lbnaddnewcharge']").live("click", function(event) {
$("#dvStage").show();
event.stopPropagation();
});

Categories

Resources