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

button event inside user control is not firing

$
0
0

i have a page with user control which is placed inside a updatepanel. In the user control,  i have a server button control. When i click the button control, button control event is not fired in the first time. if i click the button again, it fires the event.

any help.

thanks.

 

 


Getting the ClientID of ASP.NET server controls in external .js files

$
0
0

Hi,

In the aspx webform, I can put this:

  --- Javascript in ASPX:

function methodCompleted(results, context, methodName) {


            $get("<%=Button1.ClientID%>").disabled = false;
            $get("<%=lblHora.ClientID%>").innerHTML = results.toString();
 }
function getTimeBtnClicked(sender) {
    sender.disabled = true;
    PageMethods.GetTime(methodCompleted);
}

---- HTML in ASPX:
 [WebMethod]
 public static DateTime GetTime()
 {
     return DateTime.Now;
 }


And it works, I mean, I get the clientId of the server controls in runtime.

 

But the same code, in a external .js file, doesn't work.

Question 1
Obviuosly I prefer to have the javascript code on external .js files, it is possible to use <%=%> in a external .js file and execute it as a server side code?

Question 2
Is it possible to pass information of the sender object to the "methodCompleted" callback as a parameter?

 

Thanks!

UpdatePanel won't trigger SelectedIndexChanged event when default index is selected.

$
0
0

I have a RadioButtonList with a default selection (i.e., Selected="true") and AutoPostBack set to true.  In addition, I have an ASP.Net AJAX UpdatePanel around a separate control to be disabled/enabled, as applicable. The UpdatePanel triggers the aforementioned RadioButtonList control for the SelectedIndexChanged event. This works great when a user selects a ListItem from the RadioButtonListother than the default selection. However, my problem is that if the user changes his mind, and re-selects the default selection, the SelectedIndexChanged event does not fire (it does not post back).  As a result, controls that need to be disabled remain enabled. Note that I only have this problem when using the UpdatePanel. If I delete the UpdatePanel and its related controls, such that the entire page must reload, the SelectedIndexChanged control fires...even when selecting the default RadioButtonList ListItem.

Sample code is below. I would appreciate any insight into how to get ASP.Net AJAX to post back when a user re-selects the default ListItem in a RadioButtonList (note, setting the default in the page_load event didn't work either). Thanks in advance for any and all feedback!

<asp:RadioButtonList ID="rblHighestDegree" runat="server" AutoPostBack="true"
        onselectedindexchanged="rblHighestDegree_SelectedIndexChanged"><asp:listitem Runat="server" Text="Master's Degree" Selected="True" /><asp:listitem Runat="server" Text="Doctorate" /></asp:RadioButtonList>
<asp:ScriptManagerID="scriptmanager1"runat="server"/>
<asp:UpdatePanelID="updatepanel1"runat="server">
<ContentTemplate>
<asp:textbox id="txtEmployerTypeCurator" Runat="server" width="200" MaxLength="100"></asp:textbox>
</ContentTemplate>
<Triggers>
 
<asp:AsyncPostBackTriggerControlID="rblHighestDegree"EventName="SelectedIndexChanged"/>
</Triggers>
</asp:UpdatePanel>

Multiple popup in one form

$
0
0

Hi

I have to display nearly 200 popup in one web form depending on table status.  Could you tell me ? which one will be good approach to do this task?

1.  shall i design 200 popup in one form?

2. shall i keep all popups as user control  in one folder and then call that popup dynamicall ?

or is there any good approach to do this task ?

Touch Support in AJAX Control Toolkit

$
0
0

Hi,

Does anyone know if there is going to be touch support in the AJAX Control Toolkit for the controls that require it such as Slider? It seems its been an obvious and key gap for quite a while now.

If not, is the recommended suggestion to use JQUery Mobile or use JQuery UI plus hacks such ashttp://touchpunch.furf.com/ to take care of the touch support?

Thanks for reading

Can't get ajax controls to compile in visual studio 2012

$
0
0

Problems getting ajaxcontroltoolkit to work in visual studio.

I have an old asp.net website (not a projectc) that used ajax.  I just have the asp.net files.  So I did the following.  I created a bin folder, and unzipped the ajaxcontroltoolkit into it.  Then I used the Nuget Package Manager in Visual Studio to install AjaxControlToolkit.  

Then I compiled it.  I got this message:

1) Error 1 Unknown server tag 'asp:scriptmanager'. C:\shmuelKatz\Advanced2.aspx 36

and this message:

2) 

Error 11 Reference required to assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' containing the base class 'System.Web.UI.ExtenderControl'. Add one to your project. 

So I went to visual studio, and right-clicked on an empty tab, and picked "choose items" and then a dialog box popped up filled with COM objects and NET objects.  But none of them started with the word 'ajax'.

I'm puzzled.  In case there is something wrong with my web.config, here it is:

<?xml version="1.0" encoding="utf-8"?><!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
--><configuration><system.webServer><httpErrors errorMode="Detailed" /><asp scriptErrorSentToBrowser="true" /></system.webServer><system.web><customErrors mode="Off" /><pages><controls><add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" /></controls></pages></system.web></configuration>

Any help is much appreciated.

-- Gid

RowUpdating event not working with AJAX Update panel

$
0
0

Hello, There was no problem before using UpdatePanel. RowDeleting and RowUpdating is perfectly fired with image. But when I wrap my GridView with UpdatePanel the RowUpdating Panel not working however the RowDeleting is still working. Here is my GridView design: 

Code for grid view: 

<asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                        DataKeyNames="gID" DataSourceID="LinqDataSource1"
                            onrowdeleting="GridView1_RowDeleting"
                        onrowupdating="GridView1_RowUpdating" CellPadding="4" ForeColor="#333333"
                        GridLines="None" Width="244px" ShowHeader="False"><AlternatingRowStyle BackColor="White" ForeColor="#284775" /><Columns><asp:CommandField ShowDeleteButton="True" ShowEditButton="True" /><asp:TemplateField HeaderText="gID" InsertVisible="False" SortExpression="gID"><EditItemTemplate><asp:Label ID="Label1" runat="server" Text='<%# Eval("gID") %>'></asp:Label></EditItemTemplate><ItemTemplate><asp:Label ID="Label1" runat="server" Text='<%# Eval("gID") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="i"><EditItemTemplate><asp:FileUpload ID="FileUploadRowEdit" runat="server" /></EditItemTemplate><ItemTemplate><asp:Image ID="Image1" runat="server" Height="40px"
                                        ImageUrl='<%# Eval("PhotoName", "~/Gallery/{0}") %>' Width="40px" /></ItemTemplate><ControlStyle Height="40px" Width="40px" /></asp:TemplateField><asp:BoundField DataField="PortID" HeaderText="PortID"
                                SortExpression="PortID" /></Columns><EditRowStyle BackColor="#999999" /><FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /><RowStyle BackColor="#F7F6F3" ForeColor="#333333" /><SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /><SortedAscendingCellStyle BackColor="#E9E7E2" /><SortedAscendingHeaderStyle BackColor="#506C8C" /><SortedDescendingCellStyle BackColor="#FFFDF8" /><SortedDescendingHeaderStyle BackColor="#6F8DAE" /></asp:GridView><asp:LinqDataSource ID="LinqDataSource1" runat="server"
                        ContextTypeName="ImonPortdbDataContext" EnableDelete="True" EnableInsert="True"
                        EnableUpdate="True" EntityTypeName="" TableName="Galleries"
                        Where="PortID == @PortID"><WhereParameters><asp:QueryStringParameter Name="PortID" QueryStringField="id" Type="Int32" /></WhereParameters></asp:LinqDataSource></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="GridView1" EventName="RowUpdating"/></Triggers></asp:UpdatePanel>

And code for RowUpdading Event is: 

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        db = new ImonPortdbDataContext();
        FileUpload fu = (FileUpload)GridView1.Rows[e.RowIndex].FindControl("FileUploadRowEdit");

        Label lbl = (Label)GridView1.Rows[e.RowIndex].FindControl("Label1");
        int lbImglId = Convert.ToInt32(lbl.Text);
        var imgName = db.Galleries.Where(s => s.gID == lbImglId).First();
        if (fu.HasFile)
        {
            System.IO.File.Delete(Server.MapPath("~/Gallery/" + imgName.PhotoName));
            fu.SaveAs(Server.MapPath("~/Gallery/" + fu.FileName));
            e.NewValues["PhotoName"] = fu.FileName;
        }
    }

Is it possible? If so, How do I fix it? 

best regards

ehsan


Treeview/Calendar Control using AsyncPostBackTrigger not working after Security Update

$
0
0

I have an older website (developed in VS2005, .net 2.0) that has uses an asp:treeview and asp:calendar controls with an Ajax AsyncPostBack trigger to refresh an update panel based on the treeview node/calendar date selected.

We've been having a problem with an increasing number of users reporting these screens not working, and have tracked the problem down to a security update released on July 9.  (KB2846071)   Website works fine BEFORE update is applied, and is broken after update is applied.

The "broken" behavior is that the control does a full-page postback every time, instead of asynchronously, so the user just sees the screen "flash" and nothing actually changes.

The page is pretty complicated and makes significant use of the benefits of updatepanels, so I'm at a loss as to how to resolve this...?


Need to disable the script manager on child page

$
0
0

Hi Team,

I want to disable the  master page script manger on one of the child page. Please let me know if some one know that .

Thank you in an advance.

Vishal Bedre

PasswordStrength configuration regional idioma

$
0
0

Hi, my english is poor sorry , I'm from Colombia

Can I configuration regional idioma "in spanish" for property HelpStatusLabelID 

thank you

No vertical scroll bar on Accordion

$
0
0

I've got a site that uses an Accordion, it has AutoSize="Limit" and the height is set to 600, however, when rendered, the Accordion div style is set to:

"overflow-x: auto; height: 600px; overflow: hidden;"

Does anyone know why this is the case? My understanding is that an AutoSize value of Limit should render style of "overflow-y: auto;" if not "overflow: auto;"?

I tried setting the width to see if that makes any difference, but it still has "overflow: hidden".

At the moment I have a work around which places the Accordion (with AutoSize="None") in a div with a style of "height: 420px; width: 750px; overflow: auto;", but I'm surprised that this issue exists and would prefer if I didn't have to use this work around.

Accordion tag:

<AJAX:Accordion
    ID="LibraryList"
    runat="Server"
    SelectedIndex="-1"
    AutoSize="None"
    FadeTransitions="true"
    TransitionDuration="250"
    FramesPerSecond="40"
    RequireOpenedPane="false"
    HeaderCssClass="IconnedAccordionHeader"
    HeaderSelectedCssClass="IconnedAccordionHeaderSelected"
    ContentCssClass="accordionContent"
    SuppressHeaderPostbacks="true">

Rendered div:

<div id="ctl00_MainBody_LibraryList" style="height:600px;overflow:hidden;overflow-x:auto;">


 

Page Slider

$
0
0

Im trying to figure out how to implement something similar to this: http://fluidtheme.tumblr.com/. On the top right hand corner of the page if you hover over the 'tumblr' image the page slides to the left and shows a hidden "content" area. Is this a AJAX or JQuery control or is this done some other way? How would I go about implementing this on an exisiting site? Any thoughts or help is greatly appreciated. 

Thanks,

Brad

Unable to enter data into a combo box control

$
0
0

Hi,

I am new to using Ajax controIs. I have a combo box control on a web page. The control is not bound to a datasource but the items are added programmatically. 

The way I want the control to work is the user can either select one of the items from the list or they can enter data, just like a text box. When I select from the list there isn't a problem but when I try to enter data I either can't (some letters won't enter), or I get a this error message...

0x800a138f - JavaScript runtime error: Unable to get property 'createRange' of undefined or null reference

Thank you for the help!

Gary

Ajax Tool Kit Error

$
0
0

Hi Everybody,

I m getting this errot when I try to execute my website .

Compilation Error

Description:An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0117: 'AjaxControlToolkit.CalendarExtender' does not contain a definition for 'StartDate'

Source Error:

Line 15: 
Line 16:         //MediaPlayer1.MediaSource = "~/files/Wildlife.wmv";Line 17: CalendarExtender1.StartDate = DateTime.Today; Line 18:         CalendarExtender1.EndDate = DateTime.Today.AddMonths(2);
Line 19:         CalendarExtender2.StartDate = DateTime.Today.AddDays(1);


Source File: d:\inetpub\vhosts\kodact.com\busbee\CustomerHome.aspx.cs    Line: 17

I m using the below prefix, still it is showing the error.

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

Thanks in Advance.

refreshing pages with ajax web application

$
0
0

Hi guys , i have web application and i want to reload only part of a page instead of whole

for example on click i want redirect from 1.aspx to 2 aspx but wthe same ith heading and bottom 

i knnow that i should place content i want in the update panel

i know how to refresh pictures/ submit forms without reloading the page but i don't know how to make full navigation from page to page the same way

of course i can makea div in the update panel and update inner html there but it's unconvinient 

hope you help me0)0


Code in WebServices for Control Toolkit NumericUpdown

$
0
0

I want to up and down numeric button what is the code for this can help me for do this

please give code for up or down value in WebServices.asmx

 

MessageBox won't prompt out

$
0
0

Hi all,

I have a master page. Inside master page i have doing a loading update panel, pleae see below code:

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
                   <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                        </asp:ContentPlaceHolder>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="Menu1"/>
                    </Triggers>
                    </asp:UpdatePanel>
                    <asp:UpdateProgress ID="UpdateProgress1" runat="server" DynamicLayout="false" DisplayAfter="0">
                    <ProgressTemplate>
                        <div id="overlay">
                            <div id="modalprogress">
                                <div  id="theprogress">
                                    <asp:Image ID="loader" runat="server" ImageAlign="AbsMiddle" ImageUrl="~/images/ajax-loader.gif" />
                                </div>
                            </div>
                        </div>
                    </ProgressTemplate>
                    </asp:UpdateProgress>
                    <asp:UpdatePanelAnimationExtender ID="UpdatePanelAnimationExtender1" runat="server" Enabled="True" TargetControlID="UpdatePanel1">
                    </asp:UpdatePanelAnimationExtender>

I create a another new page with one button. Inside the button i have put a message box, please see below for code infront and code behind:

                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <ContentTemplate>
                        <asp:Button ID="btnSave" runat="server" BackColor="#EFF3FB"
                        onclick="btnSave_Click" style="font-family: 'Century Gothic'; height: 27px;"
                        Text="Save" />
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger  ControlID = "btnSave" EventName = "Click"/>
                        </Triggers>
                        </asp:UpdatePanel>

    protected void btnSave_Click(object sender, EventArgs e)
    {

      Toolbox.MessageBox.Show("hi");

    }

The problem is when i click the button, it didnt show me the message?Anyone can help me?

Update Progress is not working during file upload

$
0
0

In a page i have multiple file upload under update panel also i have an update progress in that page. When I am uploading files the update progress is not showing. please follow the aspx and aspx.cs code and help me.

.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/AdminMaster.master" AutoEventWireup="true" CodeFile="CreateEditDocument.aspx.cs" Inherits="CreateNewDocument" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<style type="text/css">
.auto-style1 {
width: 80%;
}
</style>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" Runat="Server">
<h3>Create New Document</h3>

<p>
<asp:Label ID="LabelCurrentUser" runat="server" Text="">Current User : </asp:Label>
<asp:Label ID="lblCurrentUser" runat="server" Text=""></asp:Label>
</p>

<p>
<asp:Label ID="LabelCurrentUserRole" runat="server" Text="">Current User Role : </asp:Label>
<asp:Label ID="lblCurrentUserRole" runat="server" Text=""></asp:Label>
</p>
<p></p>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>

<table class="auto-style1">
<tr>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
<asp:Label ID="LabelDocNumber" runat="server" Text="">Document Number :</asp:Label>
</td>
<td>
<asp:TextBox ID="txtDocNumber" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtDocNumber" ErrorMessage="*">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LabelDocSubject" runat="server" Text="">Document Subject :</asp:Label>
</td>
<td>
<asp:TextBox ID="txtDocSubject" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID ="RequiredFieldValidator2" runat="server" ErrorMessage="*" ControlToValidate="txtDocSubject">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LabelDocName" runat="server" Text="">Document Name :</asp:Label>
</td>
<td>
<asp:TextBox ID="txtDocName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID ="RequiredFieldValidator3" runat="server" ErrorMessage="*" ControlToValidate="txtDocName">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LabelDocUploadFile" runat="server" Text="">Upload Document :</asp:Label>
</td>
<td>
<asp:Panel ID="panelFileUpload" runat="server">
<asp:FileUpload ID="fuploadDoc" runat="server" Class="multi" accept=".jpg|.jpeg|.doc|.docx|.pdf|.png|.gif|.xls|.xlsx" /> <br />
</asp:Panel>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LabelUploadedFileList" runat="server" Text="Uploaded File List"></asp:Label>
</td>
<td>
<asp:Panel ID="panelUploadedFileList" runat="server">
<asp:GridView ID="gvDocFileList" runat="server" AutoGenerateColumns="False" Width="100%" OnRowDeleted="gvDocFileList_RowDeleted" OnRowDeleting="gvDocFileList_RowDeleting">
<Columns>
<asp:BoundField HeaderText="File ID" DataField="DocFileID" ReadOnly="true" />
<asp:BoundField HeaderText="Document ID" DataField="DocID" ReadOnly="true" />
<asp:TemplateField HeaderText="File Name">
<ItemTemplate>
<asp:HyperLink ID="hlinkDocFilePath" runat="server" Text='<%# Bind("DocFilePath") %>' NavigateUrl='<%#Eval("DocFilePath") %>' Target="_blank"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="Delete" ShowDeleteButton="True" />
</Columns>
</asp:GridView>
</asp:Panel>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LabelComments" runat="server" Text="">Comments :</asp:Label>
</td>
<td>
<asp:TextBox ID="txtComments" runat="server" TextMode="MultiLine" Width="300px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LabelCreatedBy" runat="server" Text="">Created By :</asp:Label>
</td>
<td>
<asp:Label ID="lblCreatedBy" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LabelCreatedDT" runat="server" Text="">Created Date Time :</asp:Label>
</td>
<td>
<asp:Label ID="lblCreatedDT" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>
<asp:Label ID="LabelDocumentPriority" runat="server" Text="">Priority :</asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlDocPriority" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LabelDocType" runat="server" Text="">Document Type :</asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlDocType" runat="server"></asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LabelDocStatus" runat="server" Text="">Document Status :</asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlDocStatus" runat="server"></asp:DropDownList>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

<tr>
<td>&nbsp;</td>
<td>
<asp:Button ID="btnCreateDocument" runat="server" Text="Create Document" CssClass="btn btn-primary" OnClick="btnCreateDocument_Click" />
&nbsp;<asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" CssClass="btn btn-danger" OnClick="btnCancel_Click" />
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>

</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<asp:Label ID="lblStatus" runat="server" Font-Bold="True" Font-Size="Medium"></asp:Label>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnCreateDocument"/>
</Triggers>
</asp:UpdatePanel>

<asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="0">
<ProgressTemplate>
<div id="LoadingDiv">
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/Loading_Images/waitAnimated.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</asp:Content>

.aspx.cs

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;

public partial class CreateNewDocument : System.Web.UI.Page
{
DMS_Functionalities objDMS = new DMS_Functionalities();
UI_Operation objUI = new UI_Operation();
LogDetails objLogDetails = new LogDetails();
Hashtable paramList = new Hashtable();
Hashtable fileParamList = new Hashtable();
DataSet ds = new DataSet();

int dsLength, saveFileFlag = 0;
string docFilePath = string.Empty;
string serverFilePath = string.Empty;
string docNumber = string.Empty;
ArrayList arrFileNames = new ArrayList();
bool status, docFileStatus;
//static int fuCounter = 0;

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["userID"] != null && Session["userRole"] != null)
{
lblCurrentUser.Text = Convert.ToString(Session["userID"]);
lblCurrentUserRole.Text = Convert.ToString(Session["userRole"]);
invisibleCreatedDetails();
}
else
{
Session.Clear();
Response.Redirect("Login.aspx");
}

fillDocTypes(ddlDocType);
fillStatus(ddlDocStatus);
fillDocPriority(ddlDocPriority);

if (Request.QueryString["DocNumber"] != null && btnCreateDocument.Text == "Create Document")
{
docNumber = Convert.ToString(Request.QueryString["DocNumber"]);
fillDocDetails(docNumber);
visibleCreatedDetails();
fillDocFileList(docNumber);
btnCreateDocument.Text = "Update Document";
txtDocNumber.Enabled = false;
}
else
{
docNumber = "NA";
LabelUploadedFileList.Visible = false;
panelUploadedFileList.Visible = false;
}
}
}

protected void fillDocDetails(string doc_Number)
{
ds = new DataSet();
ds = objDMS.getSpecificDocDetails(docNumber);

txtDocNumber.Text = docNumber;
txtDocSubject.Text = ds.Tables[0].Rows[0]["DocSubject"].ToString();
txtDocName.Text = ds.Tables[0].Rows[0]["DocName"].ToString();
txtComments.Text = ds.Tables[0].Rows[0]["DocComments"].ToString();
lblCreatedBy.Text = ds.Tables[0].Rows[0]["CreatedBy"].ToString();
lblCreatedDT.Text = ds.Tables[0].Rows[0]["CreatedDateTime"].ToString();
ddlDocStatus.Text = ds.Tables[0].Rows[0]["DocStatus"].ToString();
ddlDocPriority.Text = ds.Tables[0].Rows[0]["DocPriority"].ToString();
ddlDocType.Text = objDMS.getDocTypeForSpecificDocNumber(txtDocNumber.Text.Trim());
}

protected void fillDocFileList(string doc_Number)
{
ds = new DataSet();
ds = objDMS.getAllFilesDetailsForSpecificDoc(doc_Number);

gvDocFileList.DataSource = ds;
gvDocFileList.DataBind();
}

protected void fillStatus(DropDownList ddlStatus)
{
ds = new DataSet();
ds = objDMS.getAllStatus();

if (ds.Tables[0].Rows.Count > 0)
{
ddlStatus.Items.Clear();
dsLength = ds.Tables[0].Rows.Count;
for (int i = 0; i < dsLength; i++)
ddlStatus.Items.Add(ds.Tables[0].Rows[i][0].ToString());
}
else
ddlStatus.Items.Clear();
}

protected void fillDocPriority(DropDownList ddlPriority)
{
ds = new DataSet();
ds = objDMS.getAllPriority();

if (ds.Tables[0].Rows.Count > 0)
{
ddlPriority.Items.Clear();
dsLength = ds.Tables[0].Rows.Count;
for (int i = 0; i < dsLength; i++)
ddlPriority.Items.Add(Convert.ToString(ds.Tables[0].Rows[i][1]));
}
else
ddlPriority.Items.Clear();
}

protected void fillDocTypes(DropDownList ddlTypes)
{
ds = new DataSet();
ds = objDMS.getAllDocumentTypes();

if (ds.Tables[0].Rows.Count > 0)
{
ddlTypes.Items.Clear();
dsLength = ds.Tables[0].Rows.Count;
for (int i = 0; i < dsLength; i++)
ddlTypes.Items.Add(ds.Tables[0].Rows[i][0].ToString());
}
else
ddlTypes.Items.Clear();
}

protected void visibleCreatedDetails()
{
LabelCreatedBy.Visible = true;
LabelCreatedDT.Visible = true;
lblCreatedBy.Visible = true;
lblCreatedDT.Visible = true;
}

protected void invisibleCreatedDetails()
{
LabelCreatedBy.Visible = false;
LabelCreatedDT.Visible = false;
lblCreatedBy.Visible = false;
lblCreatedDT.Visible = false;
}

protected void uploadFilesToServer(string operation_mode)
{
HttpFileCollection files = Request.Files;
string fileName = string.Empty;
string dirPath = string.Empty;
string fileExt = string.Empty;
string countName = string.Empty;
string docFileNamePath = string.Empty;
int _maxID;
arrFileNames = new ArrayList();

_maxID = objDMS.getMaxDocFileID();

if (operation_mode == "CREATE")
{
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile file = files[i];
if (file.ContentLength > 0)
{
dirPath = Server.MapPath("~/Docs/");
fileExt = Path.GetExtension(file.FileName);
//countName = Convert.ToString(i + 1);
_maxID++;
fileName = _maxID + fileExt;
serverFilePath = dirPath + fileName;

docFileNamePath = "~/Docs/" + fileName;
arrFileNames.Add(docFileNamePath);

file.SaveAs(serverFilePath);
}
}
}
else
{
//int existFileNumber = objDMS.getNumberofFilesForSpecificDoc(txtDocNumber.Text.Trim());

for (int i = 0; i < files.Count; i++)
{
HttpPostedFile file = files[i];
if (file.ContentLength > 0)
{
dirPath = Server.MapPath("~/Docs/");
fileExt = Path.GetExtension(file.FileName);
//existFileNumber = existFileNumber + 1;
//countName = Convert.ToString(existFileNumber);
_maxID++;
fileName = _maxID + fileExt;
serverFilePath = dirPath + fileName;

docFileNamePath = "~/Docs/" + fileName;
arrFileNames.Add(docFileNamePath);

file.SaveAs(serverFilePath);
}
}
}
}

protected void saveUploadedFiles(string _mode)
{
uploadFilesToServer(_mode);
saveFileFlag = 0;
int doc_id;

// Code segment for saving all the files to the database for a particular document
if (_mode == "CREATE")
doc_id = objDMS.getMaxDocID();
else
{
ds = new DataSet();
ds = objDMS.getSpecificDocDetails(txtDocNumber.Text.Trim());
doc_id = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
}

for (int i = 0; i < arrFileNames.Count; i++)
{
fileParamList = new Hashtable();

fileParamList.Add("@opMode", "INSERT");
fileParamList.Add("@DocFileID", 0);
fileParamList.Add("@DocID", doc_id);
fileParamList.Add("@DocFilePath", arrFileNames[i].ToString());
fileParamList.Add("@ModifiedBy", lblCurrentUser.Text.Trim());
fileParamList.Add("@ModifiedDT", DateTime.Now);

docFileStatus = objDMS.CRUD_DocFileDetails(fileParamList);

if (!docFileStatus)
saveFileFlag = saveFileFlag + 1;
}
}

protected void btnCancel_Click(object sender, EventArgs e)
{
Response.Redirect("LoginHome.aspx");
}

protected void btnCreateDocument_Click(object sender, EventArgs e)
{
string operationMode = string.Empty;
System.Threading.Thread.Sleep(10000);

if (btnCreateDocument.Text == "Create Document")
{
btnCreateDocument.Text = "Please Wait...";

paramList = new Hashtable();
operationMode = "CREATE";

paramList.Add("@Mode", "INSERT");
paramList.Add("@DocNumber", txtDocNumber.Text.Trim());
paramList.Add("@DocSubject", txtDocSubject.Text.Trim());
paramList.Add("@DocName", txtDocName.Text.Trim());
paramList.Add("@DocFilePath", serverFilePath);
paramList.Add("@DocComments", txtComments.Text.Trim());
paramList.Add("@DocStatus", ddlDocStatus.Text.Trim());
paramList.Add("@CreatedBy", lblCurrentUser.Text.Trim());
paramList.Add("@CreatedDateTime", DateTime.Now);
paramList.Add("@DocTypeName", ddlDocType.Text.Trim());
paramList.Add("@DocPriority", ddlDocPriority.Text.Trim());

status = objDMS.CRUD_DocumentDetails(paramList);
saveUploadedFiles(operationMode);

if (status && saveFileFlag<=0)
{
//Log File Operation
string FileName = DateTime.Now.ToString("dd-MM-yyyy") + ".txt";
string FilePath = Server.MapPath("~/Logs/" + FileName);
string logDetails = "DocNumber " + txtDocNumber.Text.Trim() + "is created successfully at " + DateTime.Now.ToString();
objLogDetails.CreateLog(logDetails, lblCurrentUser.Text.Trim(), FilePath);
//End Log File Operation
objUI.setTextBoxesAsBlank(this);
lblStatus.Text = "New Document Created Successfully.";
lblStatus.ForeColor = System.Drawing.Color.Green;
btnCreateDocument.Text = "Create Document";
}
else
{
//Log File Operation
string FileName = DateTime.Now.ToString("dd-MM-yyyy") + ".txt";
string FilePath = Server.MapPath("~/Logs/" + FileName);
string logDetails = "DocNumber " + txtDocNumber.Text.Trim() + "saving failed at " + DateTime.Now.ToString();
objLogDetails.CreateLog(logDetails, lblCurrentUser.Text.Trim(), FilePath);
//End Log File Operation
lblStatus.Text = "New Document Saving Failed.";
lblStatus.ForeColor = System.Drawing.Color.Red;
btnCreateDocument.Text = "Create Document";
}
}
else if (btnCreateDocument.Text == "Update Document")
{
btnCreateDocument.Text = "Please Wait...";

paramList = new Hashtable();
operationMode = "EDIT";

paramList.Add("@Mode", "UPDATE");
paramList.Add("@DocNumber", txtDocNumber.Text.Trim());
paramList.Add("@DocSubject", txtDocSubject.Text.Trim());
paramList.Add("@DocName", txtDocName.Text.Trim());
paramList.Add("@DocFilePath", serverFilePath);
paramList.Add("@DocComments", txtComments.Text.Trim());
paramList.Add("@DocStatus", ddlDocStatus.Text.Trim());
paramList.Add("@CreatedBy", lblCurrentUser.Text.Trim());
paramList.Add("@CreatedDateTime", DateTime.Now);
paramList.Add("@DocTypeName", ddlDocType.Text.Trim());
paramList.Add("@DocPriority", ddlDocPriority.Text.Trim());

status = objDMS.CRUD_DocumentDetails(paramList);
saveUploadedFiles(operationMode);

if (status && saveFileFlag <= 0)
{
//Log File Operation
string FileName = DateTime.Now.ToString("dd-MM-yyyy") + ".txt";
string FilePath = Server.MapPath("~/Logs/" + FileName);
string logDetails = "DocNumber " + txtDocNumber.Text.Trim() + "is updated successfully at " + DateTime.Now.ToString();
objLogDetails.CreateLog(logDetails, lblCurrentUser.Text.Trim(), FilePath);
//End Log File Operation

fillDocFileList(txtDocNumber.Text.Trim());
objUI.setTextBoxesAsBlank(this);

lblStatus.Text = " Document Updated Successfully.";
lblStatus.ForeColor = System.Drawing.Color.Green;
btnCreateDocument.Text = "Update Document";
}
else
{
//Log File Operation
string FileName = DateTime.Now.ToString("dd-MM-yyyy") + ".txt";
string FilePath = Server.MapPath("~/Logs/" + FileName);
string logDetails = "DocNumber " + txtDocNumber.Text.Trim() + "Updation failed at " + DateTime.Now.ToString();
objLogDetails.CreateLog(logDetails, lblCurrentUser.Text.Trim(), FilePath);
//End Log File Operation

lblStatus.Text = " Document Updation Failed.";
lblStatus.ForeColor = System.Drawing.Color.Red;
btnCreateDocument.Text = "Update Document";
}
}
}

protected void gvDocFileList_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
fileParamList = new Hashtable();

fileParamList.Add("@opMode", "DELETE");
fileParamList.Add("@DocFileID", gvDocFileList.Rows[e.RowIndex].Cells[0].Text.Trim());
fileParamList.Add("@DocID", gvDocFileList.Rows[e.RowIndex].Cells[1].Text.Trim());
fileParamList.Add("@DocFilePath",gvDocFileList.Rows[e.RowIndex].Cells[2].Text.Trim());
fileParamList.Add("@ModifiedBy", lblCurrentUser.Text.Trim());
fileParamList.Add("@ModifiedDT", DateTime.Now);

status = objDMS.CRUD_DocFileDetails(fileParamList);

if (status)
{
fillDocFileList(txtDocNumber.Text.Trim());

//Log File Operation
string FileName = DateTime.Now.ToString("dd-MM-yyyy") + ".txt";
string FilePath = Server.MapPath("~/Logs/" + FileName);
string logDetails = "For the DocNumber " + txtDocNumber.Text.Trim() + "One file is deleted successfully at " + DateTime.Now.ToString();
objLogDetails.CreateLog(logDetails, lblCurrentUser.Text.Trim(), FilePath);
//End Log File Operation

lblStatus.Text = "The Record is Deleted Successfully";
lblStatus.ForeColor = System.Drawing.Color.Green;
}
else
{
fillDocFileList(txtDocNumber.Text.Trim());
lblStatus.Text = "The Record Deletion Failed.";
lblStatus.ForeColor = System.Drawing.Color.Red;
}
}

protected void gvDocFileList_RowDeleted(object sender, GridViewDeletedEventArgs e)
{
fillDocFileList(txtDocNumber.Text.Trim());
}
}

Please help me out from here.

thanks in advance.

Ajax Toolkit is affecting page load timing

$
0
0

HI all,

     This might be a duplicate thread.yet i am asking,in my page i am using ajax tabcontainer .Everthing working fine.But while testing when i looked into the page load for the first time it is taking hell a lot of time.Is there any way to compress the the axd file(scriptresource.axd).Please help me to find the solution.

Note:my page is the landing page so i cant use the caching tech.

Regards,

Hsakarp.

Get HTML Editor propertie

$
0
0

Hi

Following the example from ajax source code, i have setup a custom button to my toolbar and 2 new properties.

property 1 defines if button shows or not ( working ok ) , and property 2 would be a string value. the propertys are defined when adding the control to the form.

How can i get this value from propertie 2 in the javascript code block in the file that i defined for the button?

 

thanks

rui

Viewing all 5678 articles
Browse latest View live




Latest Images