Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

can extender be declared in codebehind

$
0
0

i have datatable loaded from session that contain checkbox , i need the value of check box be toggole button extender instead of true abnd false

here is my code 

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterForm.master" AutoEventWireup="true" CodeFile="preview.aspx.vb" Inherits="Secertaries_preview" EnableEventValidation="false" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register
Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit"
TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<link href="../css/substyle.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.modalBackground
{
background-color: Gray;
filter: alpha(opacity=80);
opacity: 0.8;
z-index: 10000;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table width="100%" align="center">


<tr>
<td style="height: 40px; text-align: left" colspan="2">

<asp:LoginView ID="LoginView1" runat="server">
<LoggedInTemplate>
You are logged in as&nbsp;<asp:Label ID="lblEmpNam" runat="server" Font-Size="Medium"
ForeColor="#CC0000" style="text-align: right"></asp:Label>
<p style="margin-left: 200px">
</LoggedInTemplate>
<AnonymousTemplate>
You are not logged in.
</AnonymousTemplate>
</asp:LoginView>
<h1> Clinic Visiting Request Form</h1>
</td>
</tr>

<tr>
<td > Date : <asp:Label ID="lbldte" runat="server" Text=""> </asp:Label>
</td>
<td style="text-align: center;" >
</td> </tr>


<tr>

<td style="text-align: left" colspan="2" >


</td>
</tr>
</table>
<div>

<div>
<asp:Label ID="Label1" runat="server" ></asp:Label>
<asp:ToolkitScriptManager ID="ScriptManager1" runat="server">

</asp:ToolkitScriptManager>
<asp:GridView ID="GridView1" runat="server" CssClass="grid"
AlternatingRowStyle-CssClass="gridAltRow" RowStyle-CssClass="gridRow" EditRowStyle-CssClass="gridEditRow"
FooterStyle-CssClass="gridFooterRow" >
<Columns>
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:ImageButton ID="imgbtn" ImageUrl="~/images/Edit.jpg" runat="server" Width="25" Height="25" onclick="imgbtn_Click" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Label ID="lblresult" runat="server"/>
<asp:Button ID="btnShowPopup" runat="server" style="display:none" />
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlpopup"
CancelControlID="btnCancel" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>
<asp:Panel ID="pnlpopup" runat="server" BackColor="White" Height="269px" Width="400px" style="display:none">
<table width="100%" style="border:Solid 3px #D55500; width:100%; height:100%" cellpadding="0" cellspacing="0">
<tr style="background-color:#D55500">
<td colspan="2" style=" height:10%; color:White; font-weight:bold; font-size:larger" align="center">User Details</td>
</tr>
<tr>
<td align="right" style=" width:45%">
UserId:
</td>
<td>
<asp:Label ID="lblID" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td align="right">
UserName:
</td>
<td>
<asp:Label ID="lblusername" runat="server"> </asp:Label>
</td>
</tr>
<tr>
<td align="right">
Employee code :
</td>
<td>
<asp:TextBox ID="txtfname" runat="server"/>
</td>
</tr>
<tr>
<td align="right">
Telephone:
</td>
<td>
<asp:TextBox ID="txtltel" runat="server" />
</td>
</tr>
<tr>
<td align="right">
General clinic:
</td>
<td>
<asp:CheckBox ID="txtGEN" runat="server"/>
<ajaxToolkit:ToggleButtonExtender ID="ToggleButtonExtenderdnt" runat="server"
TargetControlID="txtGEN"
ImageWidth="19"
ImageHeight="19"
UncheckedImageUrl="~/images/ToggleButton_Unchecked.gif"
CheckedImageUrl="~/images/ToggleButton_Checked.gif"
CheckedImageAlternateText="Check"
UncheckedImageAlternateText="UnCheck" />
</td>
</tr>
<tr>
<td align="right">
Dental Clinic:
</td>
<td>
<asp:CheckBox ID="txtDent" runat="server"/>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnUpdate" CommandName="Update" runat="server" Text="Update" onclick="btnUpdate_Click"/>
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</td>
</tr>
</table>
</asp:Panel>
<asp:button text="Submit" runat="server" id="Submit" onClick="Submit_Click" />

<asp:Button ID="Back" runat="server" Text="Back to edit" OnClick="btnBack_Click" />

</div>
<span id="result" runat="server"></span>
</div>
</asp:Content>

code behind 

Imports System.Collections
Imports System.Collections.Generic
Imports System.Data
Imports System.Diagnostics
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Data.SqlClient
Imports System.Web.Configuration
Imports System.IO
Imports Oracle.DataAccess.Client
Imports System.Drawing

Partial Class Secertaries_preview
Inherits System.Web.UI.Page
Dim dt As DataTable
Private conn As New DBConn
Private dr As OracleDataReader
Private da As OracleDataAdapter
Dim empnbr As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.Cache.SetCacheability(HttpCacheability.NoCache)
setMenu()
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache)
Response.Cache.SetNoStore()
lbldte.Text = DateAndTime.Now
If Page.PreviousPage IsNot Nothing Then
Dim GridView1 As GridView = DirectCast(Page.PreviousPage.FindControl("GridView1"), GridView)
End If
If Session("ProductsTable") IsNot Nothing Then
dt = DirectCast(Session("ProductsTable"), DataTable)
GridView1.DataSource = dt
GridView1.DataBind()
End If
' dt.Columns("Emp.Age").ColumnMapping = MappingType.Hidden
' dt.Columns(2).ColumnMapping = MappingType.Hidden

If Not IsPostBack Then
'check if the webpage is loaded for the first time.
'Saves the Previous page url in ViewState
ViewState("PreviousPage") = Request.UrlReferrer
End If
End Sub
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
' Verifies that the control is rendered


End Sub
Protected Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit.Click
dt = DirectCast(Session("ProductsTable"), DataTable)

For i As Integer = 0 To dt.Rows.Count
If Not (dt.Rows.Count = i) Then
Dim general As Char
Dim empnum As String = dt.Rows(i)("Employee code").ToString()
Dim name As String = dt.Rows(i)("Employee Name").ToString()
Dim BRNCDE As String = dt.Rows(i)("Branch(job)").ToString()
Dim EMPAGE As String = dt.Rows(i)("Emp.Age").ToString()
Dim VSTDTE As String = dt.Rows(i)("Visit date").ToString()
Dim ADDAT As String = DateTime.Now.ToShortDateString
Dim datm As DateTime = DateAndTime.Now.ToShortDateString
' datm = Convert.ToDateTime(datm.ToString("dd-mon-yyyy"))

If (dt.Rows(i)("General Clinic").ToString = True And dt.Rows(i)("Dental Clinic").ToString = True) Then
general = "3"

ElseIf (dt.Rows(i)("General Clinic").ToString = True) Then
general = "1"
ElseIf (dt.Rows(i)("Dental Clinic").ToString = True) Then
general = "2"
End If
Dim mytable As New DataTable
Try
da = conn.MyDataAdapterclnc("SELECT * FROM CLNCVST WHERE EMPNBR = '" + empnum + "' and VSTDTE='" + VSTDTE + "'")

da.Fill(mytable)
If mytable.Rows.Count > 0 Then
conn.Myupdateclnc("update clncvst set VSTDTE='" + VSTDTE + "',BRNCDE='" + general + "',CLINTYP='" + general + "',PRJCDE7='" + general + "',EMPNBR='" + empnum + "',EMPAGE='" + EMPAGE + "',ADDUSR='" + Session("empnbr") + "',ADDAT='" + ADDAT + "',UPDUSR='" + Session("empnbr")+ "', UPDDAT='" + datm + "' WHERE EMPNBR= '" + Session("empnbr") + "'and VSTDTE='" + VSTDTE + "'")


Else
conn.MyInsertclnc("INSERT INTO CLNCVST (VSTDTE,BRNCDE,CLINTYP,PRJCDE7,EMPNBR,EMPAGE,EMPSRL,RQSTSRC,ADDUSR,ADDAT) VALUES ('" + VSTDTE + "','" + EMPAGE + "','" + general + "','" + EMPAGE + "','" + empnum + "','" + EMPAGE + "','" + EMPAGE + "','" + EMPAGE + "','"+ Session("empnbr") + "','" + ADDAT + "')")

End If
Catch ex As NullReferenceException
Response.Write("Processor Usage" + ex.Message)
'the error in start generated here
End Try
End If

Next

' Response.Redirect("menu.aspx")
Server.Transfer("~/Secertaries/sucess.aspx")

End Sub
Private Sub setMenu()
Dim cph As ContentPlaceHolder = DirectCast(Master.FindControl("ContentPlaceHolder1"), ContentPlaceHolder)
Dim lv As LoginView = DirectCast(cph.FindControl("LoginView1"), LoginView)
If Session("empnam") Is Nothing Then
Response.Redirect("~/login.aspx")
End If
DirectCast(lv.FindControl("lblEmpNam"), Label).Text = Session("empnam").ToString()
End Sub
Protected Sub btnBack_Click(ByVal sender As Object, ByVal e As EventArgs)
If ViewState("PreviousPage") IsNot Nothing Then
'Check if the ViewState
'contains Previous page URL
'Redirect to
'Previous page by retrieving the PreviousPage Url from ViewState.
Session("ProductsTable") = dt
Response.Redirect(ViewState("PreviousPage").ToString())

End If
End Sub
Protected Sub OnPaging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)
GridView1.PageIndex = e.NewPageIndex
GridView1.DataBind()
End Sub
Protected Sub imgbtn_Click(ByVal sender As Object, ByVal e As ImageClickEventArgs)
Dim btndetails As ImageButton = TryCast(sender, ImageButton)
Dim gvrow As GridViewRow = DirectCast(btndetails.NamingContainer, GridViewRow)
' lblID.Text = gvdetails.DataKeys(gvrow.RowIndex).Value.ToString()
lblusername.Text = gvrow.Cells(1).Text
txtfname.Text = gvrow.Cells(2).Text
If gvrow.Cells(6).Text = True Then
ViewState(txtGEN.UniqueID) = True

Else
ViewState.Remove(txtGEN.UniqueID)

End If
If gvrow.Cells(7).Text = True Then
ViewState(txtDent.UniqueID) = True

Else
ViewState.Remove(txtDent.UniqueID)

End If
Session("empnum") = lblusername.Text
Me.ModalPopupExtender1.Show()
End Sub
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As EventArgs)
If Session("empnum") IsNot Nothing Then

Dim i As Integer = lblusername.Text

If (Session("empnum").Length <> 0) Then
If (Session("empnum").StartsWith(0)) Then
dr = conn.MyReader("SELECT DAYEMPNBR, DEMPNAM, DBRTDAT, DPRJCDE, DEMPBRN FROM DAYBAS WHERE DAYEMPNBR = '" + Session("empnum") + "' and ddayoff ='1900-01-01' ")
If dr.HasRows Then
While dr.Read()
dt.Rows(lblusername.Text - 1)("Dental Clinic") = txtDent.Checked
dt.Rows(lblusername.Text - 1)("General Clinic") = txtGEN.Checked
dt.Rows(lblusername.Text)("Employee code") = dr(0).ToString
dt.Rows(lblusername.Text)("Employee Name") = dr(1).ToString
dt.Rows(lblusername.Text)("Branch(job)") = dr(2).ToString
dt.Rows(lblusername.Text)("Emp.Age") = dr(3).ToString
Dim strEMPAGE As String = Now.Year - Convert.ToDateTime(dr(2).ToString).Year
End While

Else
txtfname.Text = Session("empnum").Text
txtfname.Text = "please check the employee code"

End If

Else
dr = conn.MyReader("SELECT EMPNAM , EMPBRTDAT , EMPPRJCDE , EMPBRN, EMPNBR FROM EMPBAS where EMPNBR ='" + txtfname.Text + "' and empmra !='12'")
If dr.HasRows Then
While dr.Read()
dt.Rows(lblusername.Text - 1)("Dental Clinic") = txtDent.Checked
dt.Rows(lblusername.Text - 1)("General Clinic") = txtGEN.Checked
dt.Rows(lblusername.Text - 1)("Employee code") = dr(4).ToString
dt.Rows(lblusername.Text - 1)("Employee Name") = dr(0).ToString
dt.Rows(lblusername.Text - 1)("Branch(job)") = dr(2).ToString
dt.Rows(lblusername.Text - 1)("Emp.Age") = Now.Year - Convert.ToDateTime(dr(1).ToString).Year
' dt.Rows(lblusername.Text - 1)("tel") = txtltel.Text
End While
Else
lblusername.Text = txtfname.Text
' txtlname.Text = "please check the employee code"

End If
End If
End If
End If
lblresult.Text = lblusername.Text + " Details Updated Successfully"
lblresult.ForeColor = Color.Green
BindGridData()
End Sub
Protected Sub BindGridData()

' da.Fill(dt)
GridView1.DataSource = dt
GridView1.DataBind()
End Sub
End Class


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>