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

PieChart display

$
0
0

Hello everybody,

I have a problem in my display with an ajax Piechart.

My code is :

Dim chtPlanif As New PieChart
Dim item As New PieChartValue
With chtPlanif
.ID = "pieChart01"
.ChartHeight = "200"
.ChartWidth = "250"
item.Category = "USA"
item.Data = "20"
chtPlanif.PieChartValues.Add(item)
item = New PieChartValue
item.Category = "China"
item.Data = "80"
chtPlanif.PieChartValues.Add(item)
item = New PieChartValue
item.Category = "UK"
item.Data = "300"
chtPlanif.PieChartValues.Add(item)

End With

and the result is not a correct pie but this:

Can you help me, I don't what is not correct in my code.

Thanks


Dynamically displaying a bunch images using Ajax

$
0
0

Hi,

I have a bunch of images stored in a List<string> storing the paths of the images which I have obtained using AjaxFileUpload.

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager><asp:ajaxfileupload ID="Ajaxfileupload1" runat="server" OnUploadComplete="FileUploadComplete" OnUploadCompleteAll="FileUploadCompleteAll" EnableViewState="true" ></asp:ajaxfileupload><asp:UpdatePanel ID="_updatePanel" runat="server"><ContentTemplate><asp:PlaceHolder ID="_ph" runat="server"></asp:PlaceHolder></ContentTemplate></asp:UpdatePanel>

In codebehind, I have

protected void FileUploadCompleteAll(object sender, System.EventArgs e)
{
  for (int i = 0; i < fN.Count; i++)
  {
     System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
     img.ImageUrl = fN[i];
     _ph.Controls.Add(img);

  }        
}

fN is a List<string> and has all the image paths.

Please let me know what wrong I am doing here and a possible fix.

Thank you

Autocomplete extender

$
0
0

Hi friends ,

               My code is execute ,but didnt get result .i cant find the error... i added WebService name in code too

Asp.net<form id="form1" runat="server"><asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"  TargetControlID ="Textbox1" ServicePath ="AutoComplete.asmx" ServiceMethod ="GetCompletionList" MinimumPrefixLength ="1" CompletionInterval ="10" EnableCaching="true" CompletionSetCount ="12" CompletionListCssClass="AutoExtender"
CompletionListItemCssClass="AutoExtenderList" CompletionListHighlightedItemCssClass="AutoExtenderHighlight" CompletionListElementID="divwidth"></asp:AutoCompleteExtender></form>

C#

public DataTable GetRecords(string strName)
    {

      
        SqlConnection con = new SqlConnection("Datasouce = XXX;database =ZZZ;Integrated Security = True");
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        cmd.CommandType = System.Data.CommandType.Text;
        cmd.Parameters.AddWithValue("@Title", strName);
        cmd.CommandText ="select PurchasedMaterial from Datesrc where PurchasedMaterial like '"+'%'+@Title+'%'+"'";
        DataSet objDs = new DataSet();
        SqlDataAdapter dAdapter = new SqlDataAdapter();
        dAdapter.SelectCommand = cmd;
        con.Open();
        dAdapter.Fill(objDs);
        con.Close();
        return objDs.Tables[0];

    
}

How fade out a label message on delete in radgrid

$
0
0

I  want to show a label message "Record deleted successfully" on deleting a record in readgrid, but the message should automatically fade out after a 5 seconds.

I have been able to do this on button click but don't know how to do this in a radgrid.

Here is the code:

ASPX:

<div id="del_error" style =" text-align:right; margin-right:20px;"><asp:Label ID="lbl_delete" runat="server" Style="white-space: nowrap" ForeColor="Red"></asp:Label></div><telerik:RadGrid ID="dgrBugs" runat="server" Width="98.7%" ShowStatusBar="true" AutoGenerateColumns="False"
OnDeleteCommand="RadGrid1_DeleteCommand" OnUpdateCommand="Update_DataGrid" AllowSorting="False"
AllowMultiRowSelection="False" AllowFilteringByColumn="false" Skin="Vista" AllowPaging="true"
PageSize="20">
-
-
-
-
-<telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"
                            HeaderText="Delete" ConfirmText="Are you sure to Delete?" /></telerik:RadGrid>

In Code behind I am trying to do this way:

Public Sub RadGrid1_DeleteCommand(source As Object, e As Telerik.Web.UI.GridCommandEventArgs)
        lbl_delete.Text = "Record deleted successfully"
        dgrBugs.Rebind()
        lbl_fade.Text = "<script>$(document).ready(function () {$('#del_error').hide(1000);});</script>"

    End Sub

not a known element !!

$
0
0

hi

i have a problem in using Ajax.
i download ASP.net Ajax 1.0 beta 2.0 and install in my pc. now i have 2 chois in my Visual studio 2005. one is Asp.net AJAX-enabled web site and other is asp.net ajax ctp-enabled web site..... i chose ajax enabled and create my web site. in my been folder i have AjaxControlToolkit.dll and microsoft.web.preview.dll .........but when i put a script manager or any ajax control such as update panel and etc, i see a red line under my code that say to me: " Element 'Script Manager' is not a known element. This can occur if there is a compilation in the web site."

please help me to fix my problem... it is very important to me.[:'(]

Modal example from tutorial website not working 1:1 copy

$
0
0

HI,

I followed this tutorial.
1:1 I copied it into my project.
But the modal does not open.
If I remove the display:none (then it shows) but using the
"close" button. It does not close.

Why is that?

http://www.aspsnippets.com/Articles/Building-Modal-Popup-using-ASPNet-AJAX-ModalPopupExtender-Control.aspx


Unable to use Ajax Control Toolkit HTML Editor

$
0
0

[VS Version: VS Pro 2013]

[.NET 4.5]

[Browser: IE 11.0.7]

Hi, 

I am trying to use the Ajax Control Toolkit to implement the HTML Editor control for an application backoffice. 

<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title></title></head><body><form id="form1" runat="server"><div><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><cc1:Editor ID="Editor1" runat="server" /></div></form></body></html>

I am getting an error as described:

"Unhandled exception at line 168, column 5 in http://localhost/53984/WebForm1.aspx. 0x800a138f - JavaScript runtime error: Unable to get property 'UI' of undefined or null reference"

The error is at the line:

"$create(Sys.Extended.UI.HTMLEditor.ToolbarButton.Undo, {"activeModesIds":"0",downSrc":"/WebResource.axd?d=HaeI...."

I have tried to change the ScriptManager to the ToolkitScriptManager but it doesn't recognize the control 

<ajaxToolkit:ToolkitScriptManagerrunat="server"ID="sm1"/>

Any tips, or work arounds?

Thanks, 

Bruno

Update panel with UpdatePanelAnimationExtender works but no progress displayed

$
0
0

Hi all, 

I have following problem: On page I have an update panel with async post back trigger and updatePanelAnimationExtender from ajax control toolkit. I want to display a part from page, and after page is loaded, then automatically update gridview with an ajax and show progress panel. Everythink works fine, gridview is updated, but no progress image is displayed. 

When I manually click on "refresh button", I get refreshed update panel and progress image is showed too. Can somebody help me, how to display progress panel automaticaly on page refresh?

here is my code:

master page:<form id="form1" runat="server"><ajaxToolkit:ToolkitScriptManager runat="server" ID="ScriptManager1"></ajaxToolkit:ToolkitScriptManager><asp:Content ID="Content2" ContentPlaceHolderID="body" Runat="Server"><script type="text/javascript">
        function onUpdating(progressContainerElementId) {
            // get the update progress div
            var updateProgressDiv = $get(progressContainerElementId);
            // make it visible
            updateProgressDiv.style.display = '';
        }
        function onUpdated(prgrsEmployees) {
            // get the divImage
            var panelProg = $get(prgrsEmployees);
            // set it to invisible
            panelProg.style.display = 'none';
        }</script><h1><asp:Literal ID="ltEmployeesTitle" runat="server" Text="<%$Resources:Employees,listTitle %>" /></h1><asp:DropDownList ID="drpEmployyesCountPerPage" runat="server"><asp:ListItem Value="5" Text="5" /></asp:DropDownList><asp:UpdatePanel ID="upEmployees" runat="server"><ContentTemplate><div id="prgrsEmployees" style="position:absolute; width:100%; height:100%; text-align:center; display:none;"><img src="Images/progress.gif" /></div><asp:GridView ID="grdEmployees" runat="server" ...><Columns>...</Columns></asp:GridView><asp:Button ID="btnShowAddEmployee" runat="server" Text="<%$Resources:Employees,add_acount %>" /></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="btnUpdateEmployees" EventName="Click" /></Triggers></asp:UpdatePanel><ajaxToolkit:UpdatePanelAnimationExtender ID="prgEmployees" TargetControlID="upEmployees" runat="server"><Animations><OnUpdating><Parallel duration="0"><ScriptAction Script="onUpdating('prgrsEmployees');" /></Parallel></OnUpdating><OnUpdated><Parallel duration="0"><ScriptAction Script="onUpdated('prgrsEmployees');" /></Parallel></OnUpdated></Animations></ajaxToolkit:UpdatePanelAnimationExtender><asp:Button ID="btnUpdateEmployees" runat="server" Text="Update Employees" OnClick="btnUpdateEmployees_Click" style="display:none;" /><script type="text/javascript">$(document).ready(function () {$(<%= btnUpdateEmployees.ClientID %>).click(); //i tried .trigger("click") too, but with the same result
    });</script>

code behind:
public partial class dashboard : BasePage
{
    int totalEmployeesCount = -1;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (totalEmployeesCount < 0)
            {
                totalEmployeesCount = DataAccount.GetAllSubAccountsCount();
            }
        }
    }

    private void RefreshEmployees()
    {
        List<Employee> employees = Get employees from DB;
        grdEmployees.DataSource = employees;
        grdEmployees.DataBind();
    }

    protected void btnUpdateEmployees_Click(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(3000);
        RefreshEmployees();
    }
}


Problem when upload image to insert using HTML editor extender

$
0
0

Hi,

i have a problem with HTML editor extender. When i upload image to insert using HTML editor extender, this error messages appear:

Unhandled exception at line 4271, column 10 in http://localhost:64438/ScriptResource.axd?d=yeSNAJTOPtPimTGCAo3LlVYSwQFFPkQzkn31D_SXQKoWnN8zdgeOyyHSgI1pOaaiVC9ge3csuOOTlhzJq8DmlJMYoxIFGSKSs6sL1e-481stzh350iA6Tc9-k2xv32rd0&t=ffffffffda74082d

 

0x800a139e - JavaScript runtime error: Sys.ArgumentException: Cannot deserialize. The data does not correspond to valid JSON.

Parameter name: data

This is my source:

 <asp:UpdatePanel ID="updatePanel1" runat="server">

                                        <ContentTemplate>

 

                                  

                                  

                                         <asp:TextBox ID="TB_editor_news" runat="server" Width="700px" Height="400px"></asp:TextBox>

                                            <asp:HtmlEditorExtender ID="TB_editor_news_HtmlEditorExtender" runat="server" Enabled="True" TargetControlID="TB_editor_news" EnableSanitization="false" OnImageUploadComplete="TB_editor_news_HtmlEditorExtender_ImageUploadComplete" DisplaySourceTab="true">

                                                <Toolbar>

                                                     <asp:BackgroundColorSelector />

                                            <asp:Bold />

                                            <asp:Copy />

                                            <asp:CreateLink />

                                            <asp:Cut />

                                            <asp:Delete />

                                            <asp:FontNameSelector />

                                            <asp:FontSizeSelector />

                                            <asp:ForeColorSelector />

                                            <asp:HorizontalSeparator />

                                            <asp:Indent />

                                            <asp:InsertHorizontalRule />

                                            <asp:InsertOrderedList />

                                            <asp:InsertUnorderedList />

                                            <asp:Italic />

                                            <asp:JustifyCenter />

                                            <asp:JustifyFull />

                                            <asp:JustifyLeft />

                                            <asp:JustifyRight />

                                            <asp:Outdent />

                                            <asp:Paste />

                                            <asp:Redo />

                                            <asp:RemoveFormat />

                                            <asp:SelectAll />

                                            <asp:StrikeThrough />

                                            <asp:Subscript />

                                            <asp:Superscript />

                                            <asp:Underline />

                                            <asp:Undo />

                                            <asp:UnLink />

                                            <asp:UnSelect />

                                            <asp:InsertImage />

                                                </Toolbar>

                                            </asp:HtmlEditorExtender>

                                            </ContentTemplate>

                                    </asp:UpdatePanel>

This is my code behind :

   protected void TB_editor_news_HtmlEditorExtender_ImageUploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)

        {

           // updatePanel1.Visible = true;

            string url = "~/Images/" + e.FileName;

            AjaxControlToolkit.AjaxFileUpload FU1 = (AjaxControlToolkit.AjaxFileUpload)sender;

            FU1.SaveAs(Server.MapPath(url));

            e.PostedUrl = Page.ResolveUrl(url);

I can upload anything images with this error. Please , help me fix it or show me how to fix it.
Please, comment soon as you can. The deadline is so close.

Note : i tried in project on my PC, everything is OK. But when i move i to web server and publish it , it's not OK

how do i use the MS AJAX JS library

$
0
0

I recently noticed a java script bounty in VS 2012 ASP.NET project. I was wondering if any of you have ever had a chance to use'em in your application

using a htmleditorextender causes problems when you want to edit the text later.

$
0
0

I have a form where has a textbox with an htmlEditorExtender.  It works.  He can format his own content, or he can paste in entire webpages from elsewhere in the web.  In source view, he sees the tags, and in regular view he sees the formatted text.

But...

I have another page where I want to let the user edit this text, if he wants to update it.  Again, I use a textbox with an htmleditorextender.

The problem is, that when I get his original markup from a database and put it into the textbox, that original markup gets encoded.  so for instance, a '<' character becomes &lt;

I think this is a bug.

If a textbox has an htmleditorextender attached to it, then it should accept markup, and not try to encode it.

But since the problem exists, is there anyway, perhaps in the 'load' event of the textbox, to decode the text coming in?

Thanks,

Slide Show Ajax

$
0
0

I get the below error when I try  to add  SlideShowAnimationType="SlideRight" to the Tag I get this from the http://www.asp.net/AjaxLibrary/AjaxControlToolkitSampleSite/SlideShow/SlideShow.aspx

Type 'AjaxControlToolkit.SlideShowExtender' does not have a public property named 'SlideShowAnimationType'.

here is my code any idea why is this !!

<asp:SlideShowExtender ID="SlideShowExtender1" runat="server"
AutoPlay="true" 
Loop="true" 
SlideShowServiceMethod="GetSlides"
TargetControlID="Image1" ClientIDMode="AutoID" Enabled="True" 
PlayInterval="900" UseContextKey="True" SlideShowAnimationType="SlideRight" ></asp:SlideShowExtender>

ajaxFileUpload

$
0
0

I want to use the ajaxFileUpload control from within a Formview, that means the user will be able to select the files but only when she Update the Formview the upload will start.

I need to hide the Upload button of the ajaxFileUpload control and then command the ajaxFileUpload control to start the upload from the Formview_itemUpdated method.

Need help of how can I achieve this ?

Other approach is welcome.

Button click event handler firing twice

$
0
0
I noticed today that button click event handlers are firing twice for me in some cases when the button is inside an UpdatePanel -- but only in Firefox.  I'm wondering if this might have to do with the Firefox 2.0.0.1 update that came out today because I never noticed this problem until today.  Has anyone else run into this problem?

Duplicate TabPanels

$
0
0

Platform: C#, VS2010, .Net Framework 4.0, AjaxToolkit v4.1.7.1213, using HTML5

At random I keep getting duplicate TAB panels generated on my aspx page, not all the time but it happens after configuring a textbox, label, and or validation control inside a tab panel; I'll change some property on a control inside a tabpanel and all of a sudden errors start appearing in the debug window saying that I have TabPanel ID(xxx) already inuse.

Attempts to fix this include removing the AjaxToolkit from the project, download a new one and reinstall; this works for awhile then starts up again.

This is on a new ASPX page with nothing more than a div header with a few labels and text boxes with and an image, then a body div tag with a scriptmanager and a 6panel ajax tab control - many thanks for any help with this.


ModalPopupExtender and ajax combobox

$
0
0

i have a ModalPopupExtender which opens a grid.then i have main grid which is in the update panel.inside this grid there is a ajax combobox.when i enter on the combobox the ModalPopupExtender is opened unwilingly.any help

Why is the AutoCompleteExtender firing the Page_Load event instead of the service method?

$
0
0

So I'm trying to implement the AutoCompleteExtender tool from the AJAX Control Toolkit.

The following is the implementation of the AutoCompleteExtender on my ASPX page:

<asp:TextBox runat="server" ID="CustomerTextBox" CssClass="form-control" /><asp:RequiredFieldValidator runat="server" ControlToValidate="CustomerTextBox"
    CssClass="text-danger" ErrorMessage="The Customer field is required." Display="None" /><ajaxToolkit:AutoCompleteExtender ID="CustomerAutoCompleteExtender" runat="server" TargetControlID="CustomerTextBox"
    MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="1" CompletionInterval="1000" 
    ServiceMethod="GetAllCustomerNames"></ajaxToolkit:AutoCompleteExtender>

This is the service method implemented in the code behind file:

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] GetAllCustomerNames(string prefixText, int count)
{

    List<string> allCustomerNames = new List<string>();
    List<Customer> allCustomers = GetAllCustomers();

    foreach (Customer customer in allCustomers)
    {
        if (customer.CustomerName.Contains(prefixText))
        {
            allCustomerNames.Add(customer.CustomerName);
        }
    }

    return allCustomerNames.ToArray();
}

The problem I'm facing is that whenever I type a character into the text box the Page_Load event fires instead of theGetAllCustomerNames method. Could someone please help me find where I'm going wrong?

Additional info:

  • I'm using Visual Studio 2013.
  • This is a ASP.NET Web Form application running on .NET 4.5.
  • I used the default style and template as when a new project is created and so a Master Page is being used.
  • The ToolkitScriptManager is specified in the Master File and I have setEnablePageMethods property to true.

Thanks in advance!

Accessing form variables with AjaxControlToolkit's AjaxFileUploader

$
0
0

Hi,

I am trying to use AjaxFileUploader to upload files. The file upload works fine.

But, I would like to access a form variable as part of AjaxFileUploader's OnUploadCompleteAll function (server side) but its not available in

codebehind for some reason. This function is called on the click of Upload button when all the uploads are complete.

<asp:TextBox ID="_branchTxtBox" runat="server" MaxLength="3"></asp:TextBox><asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" OnUploadCompleteAll="AjaxFileUpload1_UploadCompleteAll"/>

In the codebehind, I have

protected void AjaxFileUpload1_UploadCompleteAll(object sender, AjaxFileUploadCompleteAllEventArgs e)
 {

    string branchNumber = _branchTxtBox.Text.ToString(); // empty
 }

Any thoughts why the branchNumber is empty in codebehind?

Thanks

Timer Control

$
0
0

Hello,

I am implementing a timer as part of a chat functionality on my website with code I hand rolled. What it is supposed to is every 3 seconds it updates the members list so that after x amount of time it will remove members that are inactive from the list of who is in the room. It also updates the chat window for new messages posted by others. The Chat window is pulled out of a database for the last 100 messages. The database table is updated from a button when the user types it in one record per entry. Eventually I plan on purging the database table once a day to a file....

The situation I am having is as soon as I add the timer to do the updating, the retrieving of the chat window lines gets mixed up and not always placed in order of when inserted into the database, and sometimes it didnt even make it into the database... I have tried many routines trying to fix this over the past week but can not figure out what I am doing wrong....Help please

Here is my .ASP

<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="SpadesRoom1.aspx.vb" Inherits="Spades_Room1" %><asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server"><style type="text/css">
        .style137
        {
            width: 952px;
        }
        .style138
        {
            width: 214px;
        }
        .style139
        {
            height: 25px;
            }
        .style140
        {
            height: 25px;
            width: 184px;
        }
        .style142
        {
            height: 25px;
            }
        .style143
        {
            height: 25px;
            width: 160px;
        }</style></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server"><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:Timer ID="Timer1" runat="server" Interval="3600" ontick="Timer1_Tick"></asp:Timer><asp:Panel ID="Roomlist" runat="server"><br /><asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT DISTINCT [PlayerName], [Rating] FROM [Spades]"></asp:SqlDataSource>
        BANNER AD WILL GO HERE<br /><table ID="SeBkt" runat="server" align="left" class="style137" frame="border" 
            rules="all" style="background-color: #C0C0C0"><tr ID="HeadRow" runat="server"><td class="style142">&nbsp;</td><td class="style142" colspan="4">&nbsp;</td><td class="style138">&nbsp;</td></tr><tr ID="row0" runat="server"><td bgcolor="White" class="style139">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TB #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</td><td align="left" bgcolor="White" class="style139">
                    playing or Join</td><td bgcolor="White" class="style140">&nbsp;playing or Join</td><td bgcolor="White" class="style140">&nbsp;playing or Join</td><td bgcolor="White" class="style143">&nbsp;playing or Join</td><td bgcolor="White" class="style138" rowspan="3" valign="top">&nbsp;&nbsp;<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource2" 
                        PageSize="30"><Columns><asp:BoundField DataField="PlayerName" HeaderText="PlayerName" 
                                SortExpression="PlayerName" /><asp:BoundField DataField="Rating" HeaderText="Rating" 
                                SortExpression="Rating" /></Columns></asp:GridView>&nbsp;&nbsp; &nbsp;</td></tr><tr ID="row1" runat="server"><td bgcolor="#999999" class="style139" colspan="5">&nbsp;</td></tr><tr ID="row2" runat="server"><td bgcolor="White" class="style142" colspan="5"><asp:TextBox ID="Chatbox0" runat="server" BorderStyle="Solid" Height="193px" 
                        ReadOnly="True" Rows="100" style="margin-top: 0px" TextMode="MultiLine" 
                        Width="725px">this is the chat  box</asp:TextBox><script type="text/javascript">                        window.onload = function ()
                        { var textarea = document.getElementById('<%=Chatbox0.ClientID %>'); textarea.scrollTop = textarea.scrollHeight; } </script><br /><asp:TextBox ID="LinetoSubmit" runat="server" BorderStyle="Solid" Height="40px" 
                        Width="650px">Enter something here</asp:TextBox><asp:Button ID="BtnSubmitChat" runat="server" Height="40px" Text="Submit " /></td></tr></table></asp:Panel><p><asp:TextBox ID="NotLoggedIn" runat="server" BorderStyle="None" 
            Font-Bold="True" Font-Size="X-Large" ReadOnly="True" Width="766px">Sorry you need to be logged in to access this area</asp:TextBox></p><p><asp:DetailsView ID="Players" runat="server" AllowPaging="True" 
            AutoGenerateRows="False" DataSourceID="SqlDataSource1" Height="50px" 
            Width="125px" Visible="False" AutoGenerateDeleteButton="True" 
            AutoGenerateEditButton="True" AutoGenerateInsertButton="True"><Fields><asp:BoundField DataField="PlayerName" HeaderText="PlayerName" 
                    SortExpression="PlayerName" /><asp:BoundField DataField="Rating" HeaderText="Rating" 
                    SortExpression="Rating" /><asp:BoundField DataField="LastPlayed" HeaderText="LastPlayed" 
                    SortExpression="LastPlayed" /><asp:BoundField DataField="GamesWon" HeaderText="GamesWon" 
                    SortExpression="GamesWon" /><asp:BoundField DataField="GamesLost" HeaderText="GamesLost" 
                    SortExpression="GamesLost" /><asp:BoundField DataField="OnTables" HeaderText="OnTables" 
                    SortExpression="OnTables" /><asp:BoundField DataField="InRooms" HeaderText="InRooms" 
                    SortExpression="InRooms" /></Fields></asp:DetailsView><asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT * FROM [Spades]"></asp:SqlDataSource><asp:DetailsView ID="ChatView" runat="server" AllowPaging="True" 
            AutoGenerateRows="False" DataSourceID="SqlDataSource3" Height="50px" 
            Width="125px"><Fields><asp:BoundField DataField="ChatFrom" HeaderText="ChatFrom" 
                    SortExpression="ChatFrom" /><asp:BoundField DataField="ChatMessage" HeaderText="ChatMessage" 
                    SortExpression="ChatMessage" /><asp:BoundField DataField="MessageTime" HeaderText="MessageTime" 
                    SortExpression="MessageTime" /><asp:BoundField DataField="PlayersInRoom" HeaderText="PlayersInRoom" 
                    SortExpression="PlayersInRoom" /></Fields></asp:DetailsView><asp:SqlDataSource ID="SqlDataSource3" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT * FROM [SpadesRoom1Chat]"></asp:SqlDataSource><br /></p></asp:Content>

here is my codebehind

Partial Class Room1
    Inherits System.Web.UI.Page
    Dim IsAPlayer As Boolean = False
    Dim getname As String = User.Identity.Name
    Dim Temp As String
    Dim ThePlayers As String
    Dim IntervalTime As Integer = 10000


    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Session("chatinput") = LinetoSubmit.Text
        Players.PageIndex = 0
        ChatView.PageIndex = ChatView.PageCount - 1
        ChatView.DataBind()
        Players.DataBind()
        ThePlayers = ChatView.Rows.Item(3).Cells(1).Text

        If Not IsPostBack Then
            If User.Identity.IsAuthenticated = False Then
                Roomlist.Visible = False
                NotLoggedIn.Visible = True

            Else
                Roomlist.Visible = True
                NotLoggedIn.Visible = False
                'Players.Visible = True
                AddPlayerToRoom()
            End If
        End If


        LoadPlayers()
        LoadChatWindow()
        LinetoSubmit.Focus()
    End Sub

    Public Sub AddPlayerToRoom()

        'THIS SECTION ADDS A MEMBER TO THE ROOM

        End If

    End Sub
   
    Protected Sub BtnSubmitChat_Click(sender As Object, e As System.EventArgs) Handles BtnSubmitChat.Click
        
        'UPDATE TIME OF LAST ACTIVITY
        ' PLAYER INFO FOR CSV STYLE  USERNAME;RATING;LASTaCTIVITYtIMER,
        Dim SplitPlayer As Array
        Dim SplitInnerPlayer As Array
        Temp = ""
        SplitPlayer = Split(ThePlayers, ",")
        For x = 0 To SplitPlayer.Length - 1
            SplitInnerPlayer = Split(SplitPlayer(x), ";")
            If SplitInnerPlayer(0) = getname Then
                SplitInnerPlayer(2) = "0"
                SplitPlayer(x) = SplitInnerPlayer(0) & ";" & SplitInnerPlayer(1) & ";" & SplitInnerPlayer(2)
            End If
            If Temp = "" Then
                Temp = SplitPlayer(x)
            Else
                Temp = Temp & "," & SplitPlayer(x)
            End If
        Next
        ThePlayers = Temp
        If LinetoSubmit.Text <> "" Then
            SqlDataSource3.InsertCommandType = SqlDataSourceCommandType.Text
            SqlDataSource3.InsertCommand = "INSERT INTO [SpadesRoom1Chat] ([ChatFrom],[ChatMessage],[MessageTime],[PlayersInRoom]) VALUES (@ChatFrom,@ChatMessage,@MessageTime,@PlayersInRoom)"
            SqlDataSource3.InsertParameters.Add("ChatFrom", getname)
            SqlDataSource3.InsertParameters.Add("ChatMessage", LinetoSubmit.Text)
            SqlDataSource3.InsertParameters.Add("MessageTime", Today)
            SqlDataSource3.InsertParameters.Add("PlayersInRoom", ThePlayers)
            SqlDataSource3.Insert()
            ChatView.DataBind()
            LinetoSubmit.Text = ""
            Session("chatinput") = LinetoSubmit.Text
            LoadChatWindow()
        End If


    End Sub
    Public Sub LoadChatWindow()
        Dim TempChat As String = ""
        'Chatbox0.Text = ""
        If ChatView.PageCount < 100 Then
            For x = 0 To ChatView.PageCount - 1
                ChatView.PageIndex = x
                ChatView.DataBind()

                If TempChat = "" Then
                    TempChat = ChatView.Rows.Item(0).Cells(1).Text & ":>" & ChatView.Rows.Item(1).Cells(1).Text
                Else
                    TempChat = TempChat & vbCrLf & ChatView.Rows.Item(0).Cells(1).Text & ":   " & ChatView.Rows.Item(1).Cells(1).Text
                End If

            Next
        Else
            For x = ChatView.PageCount - 99 To ChatView.PageCount - 1
                ChatView.PageIndex = x
                ChatView.DataBind()

                If TempChat = "" Then
                    TempChat = ChatView.Rows.Item(0).Cells(1).Text & ":   " & ChatView.Rows.Item(1).Cells(1).Text
                Else
                    TempChat = TempChat & vbCrLf & ChatView.Rows.Item(0).Cells(1).Text & ":   " & ChatView.Rows.Item(1).Cells(1).Text
                End If

            Next
        End If
        Chatbox0.Text = TempChat
        LinetoSubmit.Focus()

    End Sub

    Public Sub LoadPlayers()

        ' PLAYER INFO FOR CSV STYLE  USERNAME;RATING;LASTACTIVE,
        Dim SplitPlayer As Array
        Dim SplitInnerPlayer As Array
        Dim LastActivityTimer As Integer

        ' Add 3 seconds to everyone
        Temp = ""
        SplitPlayer = Split(ThePlayers, ",")
        For x = 0 To SplitPlayer.Length - 1
            SplitInnerPlayer = Split(SplitPlayer(x), ";")
            SplitInnerPlayer(2) = SplitInnerPlayer(2) + 3
            SplitPlayer(x) = SplitInnerPlayer(0) & ";" & SplitInnerPlayer(1) & ";" & SplitInnerPlayer(2)
            LastActivityTimer = SplitInnerPlayer(2)
            If LastActivityTimer < 900 Then 'only keep in players in room if less than 15 minutes inactive
                If Temp = "" Then
                    Temp = SplitPlayer(x)
                Else
                    Temp = Temp & "," & SplitPlayer(x)
                End If
            End If
        Next
        ThePlayers = Temp
        'Update Database for players
        SqlDataSource3.UpdateParameters.Clear()
        SqlDataSource3.UpdateCommandType = SqlDataSourceCommandType.Text
        SqlDataSource3.UpdateCommand = "UPDATE [SpadesRoom1Chat] SET [PlayersInRoom] = @PlayersInRoom"
        SqlDataSource3.UpdateParameters.Add("PlayersInRoom", ThePlayers)
        SqlDataSource3.Update()
        ChatView.DataBind()
        'LoadChatWindow()
        GridView1.PageIndex = 0
        GridView1.DataBind()

    End Sub

    Public Sub RemovePlayerFromRoom()

        Dim PlayerRemovingIs As String = getname
        Dim PlayerRemoved As Boolean = False
        ' PLAYER INFO FOR CSV STYLE  USERNAME;RATING;LASTACTIVE,

        Dim SplitPlayer As Array
        Dim SplitInnerPlayer As Array
        Temp = ""
        SplitPlayer = Split(ThePlayers, ",")
        For x = 0 To SplitPlayer.Length - 1
            SplitInnerPlayer = Split(SplitPlayer(x), ";")
            If SplitInnerPlayer(0) <> PlayerRemovingIs Then
                If Temp = "" Then
                    Temp = SplitPlayer(x)
                Else
                    Temp = Temp & "," & SplitPlayer(x)
                End If
            End If
        Next

        ThePlayers = Temp

        SqlDataSource3.InsertCommandType = SqlDataSourceCommandType.Text
        SqlDataSource3.InsertCommand = "INSERT INTO [SpadesRoom1Chat] ([ChatFrom],[ChatMessage],[MessageTime],[PlayersInRoom]) VALUES (@ChatFrom,@ChatMessage,@MessageTime,@PlayersInRoom)"
        SqlDataSource3.InsertParameters.Add("ChatFrom", "Zoombyya.com")
        SqlDataSource3.InsertParameters.Add("ChatMessage", getname & " has left the room")
        SqlDataSource3.InsertParameters.Add("MessageTime", Today)
        SqlDataSource3.InsertParameters.Add("PlayersInRoom", ThePlayers)
        SqlDataSource3.Insert()
        ChatView.DataBind()
        'LinetoSubmit.Text = ""
        'LoadChatWindow()

    End Sub
   

    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

        Dim SplitPlayer As Array
        Dim SplitInnerPlayer As Array
        Dim IsPlayerInRoom As String
        SplitPlayer = Split(ThePlayers, ",")

        For y = 0 To GridView1.PageCount - 1
            For x = 0 To SplitPlayer.Length - 1
                SplitInnerPlayer = Split(SplitPlayer(x), ";")
                IsPlayerInRoom = SplitInnerPlayer(0)
                If e.Row.RowType = DataControlRowType.DataRow Then
                    If e.Row.Cells(0).Text <> IsPlayerInRoom Then
                        e.Row.Visible = False
                    Else
                        e.Row.Visible = True
                        'e.Row.BackColor = System.Drawing.Color.Yellow
                        'e.Row.Cells(2).BackColor = Drawing.Color.Crimson
                    End If
                End If
            Next
        Next

    End Sub

    Protected Sub Timer1_Tick(sender As Object, e As System.EventArgs) Handles Timer1.Tick

        LinetoSubmit.Focus()
    End Sub

    Protected Sub Page_LoadComplete(sender As Object, e As System.EventArgs) Handles Me.LoadComplete
        LinetoSubmit.Text = Session("chatinput")
    End Sub
End Class


 

 

 

AjaxFileUpload Tool. Set upload target dynamically

$
0
0

I'm trying to set the upload path dynamically. But the upload tool keeps taking the first path specified to the dropdownlist. It doesnt matter if I have the dropdownlist in a seperate update panel and tell the dropdownlist to stay on the selected index if there is a postback. How would I get the upload tool to use the value selected in the dropdownlist and not first value. Below is my code:

 protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                foldList.SelectedIndex = foldList.SelectedIndex;
            }
            else
            {
                Allfiles();
            }
        }
        public void Allfiles()
        {
            foldList.Items.Clear();
            String RootFold = ConfigurationSettings.AppSettings["RootPath"];
            string[] foldNames = Directory.GetDirectories(RootFold, "*", SearchOption.AllDirectories);

            foreach (string i in foldNames)
            {
                if (i.Contains(".") == true)
                {
                    //DO NOTHING
                }
                else
                {
                    foldList.Items.Add(i);
                }
            }
        }

public void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
        {
            try
            {
               
               filePath = foldList.SelectedItem.Text.ToString() + @"\" + e.FileName;
                AjaxFileUpload1.SaveAs(filepaths);
                MessageBox.Show(filepaths);

            }
            catch (Exception error)
            {
                Label1.Text=(error.Message);
            }
        }
Here Is the HTML I have tried putting the 2 different controls in seperate update panels and that hasnt worked either

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>

</head>
<body>
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<div align="center">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<asp:DropDownList ID="foldList" runat="server"
onselectedindexchanged="foldList_SelectedIndexChanged" AutoPostBack="True">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:UpdatePanel ID="UpdatePanel2" runat="server" >
<ContentTemplate>
<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server"
onuploadcomplete="AjaxFileUpload1_UploadComplete"
onuploadstart="AjaxFileUpload1_UploadStart" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>

Viewing all 5678 articles
Browse latest View live




Latest Images