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

HTMLEditorExtender formatting not working

$
0
0

Have a web-forms application with the latest HTMLEditorExtender control.  The control works fine for most users.  One user (who happens to be in a foreign country, Mexico) reports that the formatting buttons do nothing.  She highlights several words, presses the "B" for bold, and nothing happens.  None of the formatting buttons do anything for her.

Any hints or suggestions would be appreciated.


Ajax calling > async Task but doesn't load the View

$
0
0

Hi All,

I'm calling async Task<ActionResult> from ajax, and its working, I'm calling another view from this Task<ActionResult>, but when the code finish in Task<ActionResult> the view doesn't load, it still in base View.

Ajax:

function Edit(idEmployee) {$.ajax({
                url: '@Url.Action("EditEmployee/id","Employees")'.replace('id', idMain),
                type: 'post',
                dataType: 'json',
                contentType: 'application/json;charset=utf-8',
                success: function () {
                },
                error: function (error) {
                    alert(error.statusText);
                }
            });
        }

Code C#

        [HttpPost]
        public async Task<ActionResult> EditEmployee(int id)
        {
            vmEmployee VMemployee = new vmEmployee();
                    Employee emp = new Employee();
                    string apiUrl = ConfigurationManager.AppSettings["baseurl"] + "/EMPLOYEE.API/LoadEmployee";
                    var client = new HttpClient();
                    client.BaseAddress = new Uri(apiUrl);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    HttpResponseMessage responseMessage = await client.PostAsJsonAsync(apiUrl,id);
                    if (responseMessage.IsSuccessStatusCode)
                    {
                        var responseData = responseMessage.Content.ReadAsStringAsync().Result;
                        emp = JsonConvert.DeserializeObject<Employee>(responseData);
                    }
                    VMemployee.Employee= emp;

            return View("NewEmployeePage",VMemployee ); 
        }

Everything it is working fine, and the API working for retrieve object Employee, but this ajax method in View ( Employee List ) when user click on edit, I need to move to View(New Employee)... but it is not working.

By the way I mentioned in ajax > error ( alert(error.statusText)) ..... when code of Task<ActionResult> finish, I found alert > OK ???.    why the ajax going to error but I didn't found any error when I made a debug with the code?

I have one controller > Employee

I have two action method / Views in this controller > 1. EmployeeList which the one has the ajax method.                    2. NewEmployeePage , which I want to move to.

Multiple Accordions Error

$
0
0

Just updated to the latest version of ACT.  It seems now that two accordions on the same page causes error:

Multiple controls with the same ID 'h0' were found. FindControl requires that controls have unique IDs.

If you eliminate the HeaderTemplate, you get the same error except the ID is: 'c0'.  HeaderTemplates or ContentTemplates can be blank and you get the same error.   The error is very simple to replicate - just place two accordions on the same page (with HeaderTemplates).

I've found this error posted in other threads, but no solution or work around that works for me.

Any ideas?

How to show it in ajax modalpopupextender panel instead of seperate page

$
0
0

I have the following single page that shows the tags and process them:

<%@ Page Title="" Language="VB" ClientIDMode="Static" MasterPageFile="~/MasterPages/MyMasterPage.master" AutoEventWireup="false" CodeFile="Tags.aspx.vb" Inherits="NewPosting_Tags" MaintainScrollPositionOnPostback="true" %><%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %><asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"><style type="text/css">
         .MainFieldsDivStyle
        {
            border-color: Black;
            width: 70%;
            border-style: solid;
            margin-top: 22px;
            background-color:#C9DCF2;
            /*opacity: 0.8;*/
            -moz-border-radius: 15px;
            -webkit-border-radius: 15px;
            border-radius: 15px;
        }     
       .Buttonout
        {
            cursor:default;
            -moz-border-radius: 15px;
            -webkit-border-radius: 15px;
            border-radius: 15px;
        } 
         .Buttonhover
        {
            cursor:pointer;
            -moz-border-radius: 15px;
            -webkit-border-radius: 15px;
            border-radius: 15px;
        } 


                
 
        .auto-style1 {
            margin-left: 9px;
            margin-top: 7px;
        }
         


                
 
        </style><link rel="stylesheet" type="text/css" href="<%= ResolveUrl("~/jquery/js/jquery-ui.css")%>"/><link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/flick/jquery-ui.css" /><link rel="stylesheet" type="text/css" href="<%= ResolveUrl("~/jquery/js/jquery.tagit.css")%>"/></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="CpMainContent" Runat="Server"><asp:toolkitscriptmanager ID="ScriptManager1" runat="server" /><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript" charset="utf-8"></script><script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script><script src="<%=ResolveUrl("~/jquery/js/tag-it.js") %>" type="text/javascript"></script> <script type="text/javascript">$(document).ready(function () {
            var data = '<%= GetDataList() %>'; //get the available tags from code behind method.
            var datalist = data.split(","); //change the data to array$("#myTags").tagit({ availableTags: datalist });
                   // store the original data and assign  the original data to a hidden field
            // all the original data is stored in input whose name is tags
                    var tagArr = [];$.each($("input[name=tags]"), function (index, ele) {
                        tagArr.push(ele.value);
                    })$("#<%= HiddenField1.ClientID%>").val(tagArr.join(","))
             });</script><div id="MainDiv" class="MainFieldsDivStyle"><ul id="myTags"><!--render the data--><% For Each tag In tags
                %><li> <%=tag %></li><%   Next
        %></ul><%--<asp:Button ID="btnSubmit" runat="server" Text="إرسال" OnClick="btnSubmit_Click" Height="31px" Width="107px" />--%><asp:Button ID="btnSubmit" runat="server" BackColor="#6262FF" ForeColor="White" Height="40px" OnClick="btnSubmit_Click"
        style="text-align: center; font-size: 30px; margin-bottom: 5px; font-family: sc_AMEEN; -moz-border-radius: 15px;-webkit-border-radius: 15px;border-radius: 15px; " Text="إرسال" Width="186px"
        onMouseOver="this.className='Buttonhover'" onMouseOut="this.className='Buttonout'" UseSubmitBehavior="False" CssClass="auto-style1"  /><asp:HiddenField ID="HiddenField1" runat="server" /></div></asp:Content>

The code-behind is:

Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Diagnostics
Imports System.Net
Imports System.Net.Mail
Imports System.Web
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.Services
Imports System.Text
Imports System.String


Partial Class NewPosting_Tags
    Inherits System.Web.UI.Page
    Public Shared querystring As String
    Public Shared EnteredTags As String
    Public Shared UserName As String
    Public Shared tags As List(Of String) = New List(Of String)

    Protected Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click

        'EnteredTags = HiddenField1.Value
        EnteredTags = Request.Form(4)
        'Dim newTags = Request.Form("tags")

        If Len(EnteredTags) > 0 Then

            ' you want to split this input string
            Dim s As String = EnteredTags

            ' Split string based on comma
            Dim words As String() = s.Split(New Char() {","c})

            ' Use For Each loop over words and display them

            Dim conString = ConfigurationManager.ConnectionStrings("TrackingConnectionString").ConnectionString
            Using connection As New SqlConnection(conString)

                connection.Open()

                querystring = "DELETE FROM PostingsTagsTemp WHERE (LoadedByUserName=@UN)"
                Dim ClearOldRecords As New SqlCommand(querystring, connection)
                ClearOldRecords.Parameters.Add("@UN", SqlDbType.NVarChar)
                ClearOldRecords.Parameters("@UN").Value = UserName
                ClearOldRecords.ExecuteNonQuery()

            End Using


            Dim word As String
            For Each word In words
                AddNewTag(word)
            Next

        End If

        ScriptManager.RegisterStartupScript(Page, GetType(Page), "CloseWindow", "window.close();", True)

    End Sub

    'get the data list, used to populate the autocomplete available tags.
    Public Function GetDataList() As String


        Dim StoredTagsList As SqlDataReader
        Dim StoredTagsListTemp As SqlDataReader

        Dim datalist As String
        Dim data As List(Of String) = New List(Of String)()


        Dim conString = ConfigurationManager.ConnectionStrings("TrackingConnectionString").ConnectionString
        Using connection As New SqlConnection(conString)

            connection.Open()

            querystring = "SELECT DISTINCT KeyTag FROM PostingsTags"
            Dim ExtractTagsList As New SqlCommand(querystring, connection)
            ExtractTagsList.Parameters.Add("@RNo", SqlDbType.NVarChar)
            ExtractTagsList.Parameters("@RNo").Value = Session("TagsRefNo")
            StoredTagsList = ExtractTagsList.ExecuteReader()

            If StoredTagsList.HasRows Then
                Do While StoredTagsList.Read()
                    If StoredTagsList(0) <> "" Then
                        data.Add(StoredTagsList(0))
                    End If
                Loop
            End If

            StoredTagsList.Close()

            'querystring = "SELECT DISTINCT KeyTag FROM PostingsTagsTemp WHERE (LoadedByUserName=@UN)"
            querystring = "SELECT DISTINCT KeyTag FROM PostingsTagsTemp"
            Dim ExtractTagsListTemp As New SqlCommand(querystring, connection)
            ExtractTagsListTemp.Parameters.Add("@UN", SqlDbType.NVarChar)
            ExtractTagsListTemp.Parameters("@UN").Value = UserName
            StoredTagsListTemp = ExtractTagsListTemp.ExecuteReader()

            If StoredTagsListTemp.HasRows Then
                Do While StoredTagsListTemp.Read()
                    If StoredTagsListTemp(0) <> "" Then
                        'data.Remove(StoredTagsListTemp(0))
                        data.Add(StoredTagsListTemp(0))
                    End If
                Loop
            End If

            StoredTagsListTemp.Close()



        End Using


        datalist = String.Join(",", data)
        Return datalist

    End Function

    Public Sub AddNewTag(ByVal Tag As String)

        Dim conString = ConfigurationManager.ConnectionStrings("TrackingConnectionString").ConnectionString
        Using connection As New SqlConnection(conString)

            connection.Open()


            querystring = "INSERT INTO PostingsTagsTemp(RefNo,KeyTag,LoadedByUserName) VALUES(@RNo,@Tag,@UN)"
            Dim InsertNewTag As New SqlCommand(querystring, connection)
            InsertNewTag.Parameters.Add("@RNo", SqlDbType.NVarChar)
            InsertNewTag.Parameters("@RNo").Value = Session("TagsRefNo")
            InsertNewTag.Parameters.Add("@Tag", SqlDbType.NVarChar)
            InsertNewTag.Parameters("@Tag").Value = Tag
            InsertNewTag.Parameters.Add("@UN", SqlDbType.NVarChar)
            InsertNewTag.Parameters("@UN").Value = UserName
            InsertNewTag.ExecuteNonQuery()



        End Using


    End Sub

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

        If Session("UserName") = "" Then
            Response.Redirect("~\Logon\LogonScreen.aspx")
        End If

        UserName = Session("username")

        btnSubmit.Focus()
        Dim RefNoKeyTags As SqlDataReader
        Dim conString = ConfigurationManager.ConnectionStrings("TrackingConnectionString").ConnectionString
        Using connection As New SqlConnection(conString)

            connection.Open()


            If IsPostBack = False Then


                If tags.Count > 0 Then
                    tags.Clear()
                End If

                querystring = "SELECT DISTINCT KeyTag FROM PostingsTagsTemp WHERE (LoadedByUserName=@UN)"
                Dim LoadRefNoKeyTags As New SqlCommand(querystring, connection)
                LoadRefNoKeyTags.Parameters.Add("@UN", SqlDbType.NVarChar)
                LoadRefNoKeyTags.Parameters("@UN").Value = UserName
                RefNoKeyTags = LoadRefNoKeyTags.ExecuteReader()

                If RefNoKeyTags.HasRows Then
                    While RefNoKeyTags.Read()
                        tags.Add(RefNoKeyTags(0))
                    End While
                    RefNoKeyTags.Close()
                End If

            End If

        End Using

    End Sub



End Class

What I want is to show them in ajax modalpopupextender panel, for example:

<asp:Panel ID="Panel1" runat="server" CssClass="Panel1Style" style="display:none" ><table id="TagsTable" runat="server" style="width:100%;"><tr>
.
.<td>
.
.
</td>
.
.</tr></table> </panel> <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" CancelControlID="Panel1Cancel" PopupControlID="Panel1" DropShadow="true" TargetControlID="Panel1DummyLabel" BackgroundCssClass="modalBackground"></asp:ModalPopupExtender>

With code-behind, as example:

Protected Sub OpenTagsForm_Click(sender As Object, e As EventArgs) Handles OpenIncomingInfoWindow.Click
      ModalPopupExtender1.Show()
End Sub

So, how to make it?

Value not updating according to array when there asp:Timer control

$
0
0

Hi,

I would need to update a value and the label colour of the value accordingly, it should show red if the value does not match the value in the array, green otherwise. 

This is my code, my code looks so messy, I seriously am not sure if I am using the Timer control properly. I need the interval set to 10, as the moment the data is updated in the database, it should automatically show on the page. However, the colour of the value must change accordingly. 

<%@ Page Title="" Language="C#" MasterPageFile="~/Progress.Master" AutoEventWireup="true" CodeBehind="Progress-ManRoland1.aspx.cs" Inherits="WebApplication1.Progress_ManRoland1" %><asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><asp:Timer runat="server" ID="Timer1" Interval="10" OnTick="IncreaseCount"></asp:Timer><div class="container"><asp:Label ID="Label0" runat="server" Text="Label" CssClass="font-size-progress"></asp:Label><asp:Label ID="lblslash" runat="server" Text="/" ForeColor="WindowFrame" CssClass="font-size-progress"></asp:Label><asp:Label ID="Label1" runat="server" Text="Label" CssClass ="font-size-progress" ForeColor="WhiteSmoke"></asp:Label><h1>  <asp:Label ID="lblReasonCode" runat="server" Text="Label" ForeColor="White"></asp:Label></h1><p><asp:Label ID="lblTime" runat="server" /></p>  </div><br /><%--  <asp:Timer ID="aTimer" runat="server" OnTick="IncreaseCount" Interval="3600000" />--%></ContentTemplate></asp:UpdatePanel></asp:Content>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Configuration;
using System.Data.OleDb;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.Data.SqlClient;
using System.Drawing;


namespace WebApplication1
{
    public partial class Progress_ManRoland1 : System.Web.UI.Page
    {
        DataSet DS = new DataSet();
        int pallettqtybyshift = 0;
        double[] morningshift = new double[13];
        DateTime[] hourtable2 = new DateTime[13];
        

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                //during first Page Load
                lblTime.Text = DateTime.Now.ToString("hh:mm:ss tt");
                Label1.Text = GetCurrentShiftPalletteQuantity().ToString();
                //Label0.Text = GetPalletteCount_dblcountingmachine().ToString();
            }
            else
            {
                //if Postback occurs
                //Response.Write("Postback occurs");

            }
        }

        private DataSet GetData(string SPName, SqlParameter SPParameter, SqlParameter SPParameter1)
        {
            string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
            SqlConnection con = new SqlConnection(CS);
            SqlDataAdapter da = new SqlDataAdapter(SPName, con);
            da.SelectCommand.CommandType = CommandType.StoredProcedure;
            if (SPParameter != null)
            {
                da.SelectCommand.Parameters.Add(SPParameter);
                da.SelectCommand.Parameters.Add(SPParameter1);

            }
            DataSet DS = new DataSet();
            da.Fill(DS);
            return DS;
        }

        private DataSet OMplanner(string SPName, SqlParameter SPParameter, SqlParameter SPParameter1)
        {
            string CS = ConfigurationManager.ConnectionStrings["OMplanner"].ConnectionString;

            SqlConnection con1 = new SqlConnection(CS);
            SqlDataAdapter da1 = new SqlDataAdapter(SPName, con1);
            da1.SelectCommand.CommandType = CommandType.StoredProcedure;
            if (SPParameter != null)
            {
                da1.SelectCommand.Parameters.Add(SPParameter);
                da1.SelectCommand.Parameters.Add(SPParameter1);

            }
            DataSet DS1 = new DataSet();
            da1.Fill(DS1);
            return DS1;
        }

        protected void IncreaseCount(object sender, EventArgs e)
        {
           lblTime.Text = DateTime.Now.ToString("hh:mm:ss tt");
            hourtable2 = FillupHourTable();
            morningshift = ExpectedTable();
            Label0.Text = GetPalletteCount_dblcountingmachine().ToString();
           int everytickcount = Convert.ToInt32(Label0.Text);
           int expectedtarget;

            for (int i = 0; i < hourtable2.Length; i++)
            {
                expectedtarget = Convert.ToInt32(Math.Round(morningshift[i], 0));
                if (DateTime.Now == hourtable2[i])
                {
                    if (everytickcount >= expectedtarget)
                    {
                        Label0.ForeColor = Color.Green;
                    }
                    else
                    {
                        Label0.ForeColor = Color.Red;
                    }
                }
            }
        }

        private int GetCurrentShiftPalletteQuantity()
        {
            DateTime currenttime = DateTime.Now;
            SqlParameter parameter0 = new SqlParameter("@currentdate", currenttime.ToShortDateString());
            SqlParameter parameter1 = new SqlParameter("@currenttime", currenttime.ToString("hh:mm:ss tt"));
            DataSet DS = GetData("GET_MAN1_CurrentShiftData", parameter0, parameter1);
            string reasoncode = DS.Tables[0].Rows[0][1].ToString();
            ReasonCode(reasoncode);


            double tgt_palletteqtypershift = Convert.ToDouble(DS.Tables[0].Rows[0][0].ToString());
            return Convert.ToInt32(Math.Round(tgt_palletteqtypershift, 0));
            
        }

        private int GetPalletteCount_dblcountingmachine()
        {
            DateTime currenttime = DateTime.Now;
            SqlParameter machineid = new SqlParameter("@machineid", 3);
            SqlParameter timestampdate = new SqlParameter("@currentdate", currenttime.ToString("yyyy-MM-dd"));
            DataSet newds = OMplanner("TimeStampdetails", machineid, timestampdate);
            int tickcount = Convert.ToInt32(newds.Tables[0].Rows[0][0].ToString());
            return tickcount;
        }

        private void ReasonCode(string code)
        {
            if(code == "0")
            {
                lblReasonCode.Text = "Make Ready";
            }
            else if (code == "1")
            {
                lblReasonCode.Text = "Active";
            }
            else if (code == "2")
            {
                lblReasonCode.Text = "Breakdown";
            }
            else if (code == "3")
            {
                lblReasonCode.Text = "Maintenance";
            }
            else if (code == "4")
            {
                lblReasonCode.Text = "No Work";
            }
            else if (code == "5")
            {
                lblReasonCode.Text = "Plate Change";
            }
            else if (code == "6")
            {
                lblReasonCode.Text = "Cycle Service";
            }
        }

        private DateTime[] FillupHourTable()
        {
            TimeSpan startime_firstshift = new TimeSpan(14, 54, 0);
            TimeSpan addhour = new TimeSpan(0, 2, 0 );
            DateTime[] hourtable = new DateTime[13];


            for (int i = 0; i < hourtable.Length; i++)
            {
                hourtable[i] = DateTime.Today.Add(startime_firstshift);
                //Response.Write(hourtable[i]);
                //Response.Write('\n');
                startime_firstshift = startime_firstshift + addhour;
            }

            return hourtable;
        }

        private double[] ExpectedTable()
        {
            pallettqtybyshift = GetCurrentShiftPalletteQuantity();
            double averageplt_hourly = Math.Round(Convert.ToDouble(pallettqtybyshift) / 12,2);
            //Response.Write(averageplt_hourly);
            //morningshift = new double[13];
            double[] morningshift = new double[13];
            for (int i = 0; i < morningshift.Length; i++)
            {
                if(i == 0)
                {
                    morningshift[i] = 0;
                    //Response.Write(morningshift[i]);
                }
                else
                {
                    morningshift[i] = averageplt_hourly + morningshift[i - 1];
                    //Response.Write(morningshift[i]);
                }
                //Response.Write('\n');
            }

            return morningshift;
        }



    }
}

call action from another project in same solution

$
0
0

Hello,

I have two project in one solution, I have an action in first project 

    [Route("[controller]/[action]")]
public class HomeController : Controller
{
[HttpGet] public string Index() { return "Hi"; }
}

I tried this in second project , but its not working.

Note: By the way, I did dependecy

$.ajax({
                    url: 'https://localhost:xxx/Home/Index',
                    type: 'get',
                    dataType: 'json',
                    contentType: 'application/json;charset=utf-8',
                    success: function (data) {
                        alert('Success: ' + data);
                    },
                    error: function (error) {
                        alert(error.statusText);
                    }
                });

Update Panel Not Working - ASP.NET

$
0
0

Hey all,

This is my first post so hope everyone is ok and keen to help a person just joined!

I have added an update Panel around my Table and added a trigger button, but it seems to always update on post back. 

My requirements are;

  • Update on ititial Page Load
  • Do not update on PostBack

This is my ASP.NET Code

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:Button ID="Button1" runat="server" Text="Button" /><asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional"> <Triggers><asp:PostBackTrigger ControlID="Button1" /></Triggers><ContentTemplate> <asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="false" CssClass="Grid" AlternatingRowStyle-CssClass="alt"
        DataKeyNames="UserName" OnRowDataBound="OnRowDataBound"><Columns><asp:TemplateField><ItemTemplate><img alt = "" style="cursor: pointer" src="../images/plus.png" /><asp:Panel ID="pnlOrders" runat="server" Style="display: none"><asp:GridView ID="gvOrders" runat="server" AutoGenerateColumns="false" CssClass = "Grid" OnRowCommand="OnRowCommand">  <Columns><asp:BoundField ItemStyle-Width="150px" DataField="UserID" HeaderText="UserID" /></Columns></asp:GridView></asp:Panel></ItemTemplate></asp:TemplateField><asp:BoundField ItemStyle-Width="200px" DataField="UserName" HeaderText="UserName" /><asp:BoundField ItemStyle-Width="200px" DataField="Access" HeaderText="Access" /><asp:BoundField ItemStyle-Width="200px" DataField="FullName" HeaderText="Name" /></Columns></asp:GridView><br /><br /><br /><br /><script type="text/javascript" src="../jquery/jquery-1.8.3.min.js"></script><script type="text/javascript">$("[src*=plus]").live("click", function () {$(this).closest("tr").after("<tr><td></td><td colspan = '999'>" + $(this).next().html() + "</td></tr>")$(this).attr("src", "../images/minus.png");

            });

            $("[src*=minus]").live("click", function () {$(this).attr("src", "../images/plus.png");$(this).closest("tr").next().remove();
            });</script></ContentTemplate> </asp:UpdatePanel> 

On my page i have added the background code in VB.NET

        If Not IsPostBack Then

            Dim strSQL As String
            strSQL = "SELECT UserName, UserName, Access, FullName "
            strSQL = strSQL & "FROM TblDefaultUsers "

            gvCustomers.DataSource = GetData(strSQL)
            gvCustomers.DataBind()

        End If

Any ideas.

Thank you

Jason

UpdatePanel - Button Outside Not Postback

$
0
0

I'm a newbie with a newbie question.  I have a test page testing the UpdatePanel.  I have a Panel then UpdatePanel inside with two TextBoxes inside. TB1 has calendar extender with Postback that just puts the same date in TB2.   This works perfectly with the UpdatePanel. 

All I want to do is have the Button postback so it will run the code behind to just put "Hello" in TB2.  The button is OUTSIDE of the UpdatePanel but inside the Panel.  It does nothing when I click it and I don't get my hello. What am I doing wrong?

<body><form id="form1" runat="server"><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:Panel ID="Panel1" runat="server"><asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"></asp:TextBox><ajaxToolkit:CalendarExtender ID="TextBox1_CalendarExtender" runat="server" BehaviorID="TextBox1_CalendarExtender" TargetControlID="TextBox1" /><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></ContentTemplate></asp:UpdatePanel><br /><br /><asp:Button ID="Button1" runat="server" Text="Button" /></asp:Panel></form></body>
Public Class Delete
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        TextBox2.Text = TextBox1.Text
    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        TextBox2.Text = "hello"
    End Sub
End Class

Thanks for your help in advance from a Newbie!!!


refresh only part of page whit tabs

$
0
0

Hello,

I have a master page and one content page.

In the content page i have tabs .Each tab is a button and when clicking on the button(tab) it activate the according view.

In each view i have a usercontrol that have gridView with data that is loaded.

My problem is that when i click on a tab it will refresh the whole page and will call in each page load event of all the usercontrol of each view.

How can i change my code so that when clicking on a tab it will only load the page load event of this tab.

Thank you

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.master" CodeBehind="Main.aspx.cs" Inherits="SysManagement.Main" EnableEventValidation="false" %><%@ Register Src="~/WebUserControl_Users.ascx" TagName="UsersControl" TagPrefix="TWebControl" %><%@ Register Src="~/WebUserControl_Equipments.ascx" TagName="EquipmentsControl" TagPrefix="TWebControl" %><%@ Register Src="~/WebUserControl_OpSys.ascx" TagName="OpSysControl" TagPrefix="TWebControl" %><asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"></asp:Content><asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"><table width="100%" align="center"><tr><td><asp:Button Text="user" BorderStyle="None" ID="TabUser" CssClass="Initial" runat="server" OnClick="TabUser_Click" /><asp:Button Text="equipment" BorderStyle="None" ID="TabEquipment" CssClass="Initial" runat="server" OnClick="TabEquipment_Click" /><asp:Button Text="operating sys" BorderStyle="None" ID="TabOpSys" CssClass="Initial" runat="server" OnClick="TabOpSys_Click" /><asp:MultiView ID="MainView" runat="server"><asp:View ID="ViewUser" runat="server"><TWebControl:UsersControl ID="Tab_users" runat="server" /></asp:View><asp:View ID="ViewEquipment" runat="server"><TWebControl:EquipmentsControl ID="Tab_equipments" runat="server" /></asp:View><asp:View ID="ViewOpSys" runat="server"><TWebControl:OpSysControl ID="Tab_opsys" runat="server" /></asp:View></asp:MultiView></td></tr></table></asp:Content>

//in the content page server side event when clicking on the button to activate the view.
protected void TabUser_Click(object sender, EventArgs e)
{

TabUser.CssClass = "Clicked";
TabEquipment.CssClass = "Initial";
TabOpSys.CssClass = "Initial";
MainView.ActiveViewIndex = 0;

}

//in the usercontrol server side function to bind the grid
public partial class WebUserControl_Frequency : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
BindGridFrequency();
}
}
{

Label value does not change with ajax timer

$
0
0

having an ajax timer running to check connection, 

wondering why the label lblsessiontimeleft inside update panel udpSession does not change accordingly, meant for it to decrease its value by one second thereafter

protected void TimerSession_Tick(object sender, EventArgs e)
  {
    recheckconn();

    if ((string)Session["sConnLetter"] == "c")
    {
      DateTime datetimenow = DateTime.Now;
      DateTime datetimesession;
      datetimesession = datetimenow.AddMilliseconds((int)Session["sSessionTimeout"]);

      TimeSpan tstd;
      TimeSpan tstd1;

      tstd = datetimesession.AddMilliseconds((int)Session["sSessionTimeout"]) - DateTime.Now;
      tstd1 = tstd.Subtract(new TimeSpan(0, 0, 1));

      if (Session["sSessionTimeout1"] != null)
      {
        Session["sTimeDifferent"] = datetimesession.AddMilliseconds((int)Session["sSessionTimeout1"]) - DateTime.Now;
        tstd = datetimesession.AddMilliseconds((int)Session["sSessionTimeout1"]) - DateTime.Now;
        tstd1 = tstd.Subtract(new TimeSpan(0, 0, 1));
      }

      Session["sSessionTimeout1"] = tstd1.Milliseconds;

      lblsessiontimeleft.Text = tstd1.Milliseconds.ToString();

      pnlSession.Style.Add("display", "block");
      udpSession.Update();

    }

Hide fields inside modal popup extender using JS

$
0
0

Hi,

I would like to show/hide some fields inside a popup extender, based on a radio button list value selection (InternalExternal_RadioButtonList).

My problem is that the minute the js function (mailTypeChanged) finishes running, the pop up panel is closed.

This is my code:

<asp:Panel ID="sendEmailPanel" CssClass="ModalWindowEmail" style = "display:nonetext-align:left;" runat="server">                        <div class="popup_header">                            Send Email                        </div>                        <div class="popup_BodyEmail">                                    <asp:RadioButtonList ID="InternalExternal_RadioButtonList" AutoPostBack="true" runat="server" RepeatDirection="Horizontal">                                        <asp:ListItem Selected="True" onclick="mailTypeChanged(this);">External</asp:ListItem>                                        <asp:ListItem onclick="mailTypeChanged(this);">Internal</asp:ListItem>                                    </asp:RadioButtonList>                                    <asp:TextBox ID="mailToDate" TextMode="Date" runat="server" Width="250px"></asp:TextBox>                                    <ajaxToolkit:TextBoxWatermarkExtender ID="mailToDate_WM" runat="server"                                        TargetControlID="mailToDate"                                        WatermarkText="Date"                                        WatermarkCssClass="watermarked" />                                                               <p><asp:TextBox ID="mailRecipients" runat="server" Width="250px"></asp:TextBox></p>                                    <ajaxToolkit:TextBoxWatermarkExtender ID="mailRecipients_WM" runat="server"                                        TargetControlID="mailRecipients"                                        WatermarkText="To"                                        WatermarkCssClass="watermarked" />                                    <p><asp:TextBox ID="mailCc" runat="server" Width="250px"></asp:TextBox></p>                                    <ajaxToolkit:TextBoxWatermarkExtender ID="mailCc_WM" runat="server"                                        TargetControlID="mailCc"                                        WatermarkText="CC"                                        WatermarkCssClass="watermarked" />                                    <p><asp:TextBox ID="mailBcc" runat="server" Width="250px"></asp:TextBox></p>                                    <ajaxToolkit:TextBoxWatermarkExtender ID="mailBcc_WM" runat="server"                                        TargetControlID="mailBcc"                                        WatermarkText="BCC"                                        WatermarkCssClass="watermarked" />                                    <p><asp:TextBox ID="mailBody" runat="server" TextMode="MultiLine" Width="250px" Height="250px"></asp:TextBox></p>                                    <ajaxToolkit:TextBoxWatermarkExtender ID="mailBody_WM" runat="server"                                        TargetControlID="mailBody"                                        WatermarkText="Body"                                        WatermarkCssClass="watermarked" />                                                      </div>                        <div class="popup_ButtonsEmail">                            <asp:Button ID="sendMail" runat="server" Text="Send" OnClick="ValidationOK_Click"/>                            <asp:Button ID="emailCancel" runat="server" Text="Cancel" OnClientClick="skm_unLockScreen('skm_LockPane')"/>                        </div>                    </asp:Panel>                    <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender4" runat="server"                         TargetControlID="email"  CancelControlID="emailCancel" PopupControlID="sendEmailPanel" DropShadow="true" BackgroundCssClass="modalBackground">                        <Animations>                            <OnShown>                                <FadeIn Duration=".4" Fps="20" />                                            </OnShown>                        </Animations>                    </ajaxToolkit:ModalPopupExtender>
function mailTypeChanged(id)        {            alert(id.value);                    }

Change date inside TextBox with TextBoxWatermarkExtender

$
0
0

Hi,

How can I change the date inside a TextBox with TextMode="Date" that uses a TextBoxWatermarkExtender?

I can't seem to do it from code behind:

<asp:TextBox ID="mailToDate" TextMode="Date" runat="server" Width="250px"></asp:TextBox>                                    <ajaxToolkit:TextBoxWatermarkExtender ID="mailToDate_WM" runat="server"                                        TargetControlID="mailToDate"                                        WatermarkText="Date"                                        WatermarkCssClass="watermarked" />
mailToDate.Enabled = true;                mailToDate_WM.Enabled = true;                mailToDate.Text = DateTime.Now.ToShortDateString();

Hiding Modalpopupextender vs Response.Write/End

$
0
0

I have an issue with a page on a larger project which I've mapped to a standalone, smaller project to isolate the issue and aid experimentation.

In essence, the page has a button which pops up a modal with an n-choice selection (for simplicity, two in the example). The choice of button determines which of two slightly difference files to download. Clicking the button should also dismiss the modal popup.

I cannot get both to happen! As it stands, I can download, but the modal popup remains. Previously, before I added PostBackTriggers for both *_Click events, the modal popup would hide, but no download would happen. Currently, the order of Response.* calls vs modal popup hide appears not to be significant.

Is there a way of coding this such that both happen? Is AjaxToolkit the right way to go? Can I do something with postbacks? This, as you might have gathered, is not my area of expertise, so all advice and tips would be very gratefully received!

Here's my aspx:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Popup_Test_4._5.WebForm1" %><asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"><asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server"></asp:ScriptManagerProxy><asp:Button ID="SaveFileDirectly" runat="server" Text="Save (Direct)" ToolTip="Save file directly" OnClick="SaveFileDirectly_Click" Style="width: 100px; margin-left: 5px;" /><asp:Button ID="SaveFileIndirectly" runat="server" Text="Save (Indirect)" ToolTip="Save file indirectly" OnClick="SaveFileIndirectly_Click" Style="width: 100px; margin-left: 5px;" /><asp:Button ID="LanguageControl" runat="server" Style="display: none;" /><ajaxtoolkit:modalpopupextender id="LanguageModalPopup" popupcontrolid="LanguagePanel" targetcontrolid="LanguageControl" backgroundcssclass="modalBackground" runat="server"></ajaxtoolkit:modalpopupextender><asp:Panel ID="LanguagePanel" Style="display: none;" runat="server"><asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><p>Which language?</p><div style="text-align: right; margin-top: 10px;"><asp:Button ID="EnglishButton" Text="English" runat="server" OnClick="EnglishButton_Click" /><asp:Button ID="FrenchButton" Text="French" runat="server" OnClick="FrenchButton_Click" /></div></ContentTemplate><Triggers><asp:PostBackTrigger ControlID="EnglishButton" /><asp:PostBackTrigger ControlID="FrenchButton" /></Triggers></asp:UpdatePanel></asp:Panel></asp:Content>

and C#:

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

namespace Popup_Test_4._5
{
	public partial class WebForm1 : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
		}

		protected void CommonResponse(bool english = true)
		{
			this.Response.Clear();
			this.Response.Buffer = true;
			this.Response.ContentType = "text/xxx";
			this.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", "testdownload.xxx"));
			this.Response.Write(english ? "hello" : "bonjour");
			this.Response.End();
		}

		protected void SaveFileDirectly_Click(object sender, EventArgs e)
		{
			CommonResponse();
		}

		protected void SaveFileIndirectly_Click(object sender, EventArgs e)
		{
			LanguagePanel.Style["display"] = "block";
			LanguageModalPopup.Show();
		}

		protected void EnglishButton_Click(object sender, EventArgs e)
		{
			LanguagePanel.Style["display"] = "none";
			LanguageModalPopup.Hide();
			CommonResponse();
		}

		protected void FrenchButton_Click(object sender, EventArgs e)
		{
			CommonResponse(false);
			LanguagePanel.Style["display"] = "none";
			LanguageModalPopup.Hide();
		}
	}
}

Ajax run part of code (a defer)before it moves onto the next part.

$
0
0

I have some code that is being called and it goes through the beginning of my $.ajax() I need this to go through my whole method before it exits and goes to the next part because it is not put together properly until it runs all the way through. Currently it starts and then exits skipping my defer and goes into the if (woimageindex >= 0) condition

Here is my code that I have. I need if (woimageindex == -1) to run and go through defer.done(function () { but it skips everything in this section. How can I make it do this before moving on?

if (woimageindex == -1)//item not found
                        {
                            var ajaxRequests = [];

                            url = rootPath + "utility/GetWebRequestImages";                          

                            ajaxRequests.push($.ajax({
                                type: 'POST',
                                url: url,
                                data: {
                                     corp_id: WOCorp_id
                                },
                                dataType: 'json'
                            }));

                            var defer = $.when.apply($, ajaxRequests);
                            defer.done(function () {
                                // This is executed only after every ajax request has been completed$.each(arguments, function (index, responseData) {
                                    switch (index) {
                                        case 0://status
                                            //populate the AutoCompleteDataSource with the data from server
                                            arrWOWebRequestImagesList.push(new PickListModel(WOCorp_id, responseData));
                                            woimageindex = arrWOWebRequestImagesList.length - 1;
                                            break;
                                    }
                                    //alert(index);
                                });//end of switch
                            });//end of defer
                        }
                        if (woimageindex >= 0)
                        {
                            var categories = arrWOWebRequestImagesList[woimageindex].list;
                            alert(categories.length);
                            var list = [];

                            // added new PickListModel(webimage_id, after .push(
                                //list.push(new PickListModel(webimage_id, $.map(arrWOWebRequestImagesList[woimageindex].list, function (item) {
                            list.push( $.map(arrWOWebRequestImagesList[woimageindex].list, function (item) {
                                return new PickListItem(item.caption, item.caption, item.webimage_id);
                            }));

Change the selected row css from codebehind

$
0
0

Hi,

I would like to change the selected row background color after the user clicks the "View Rec." link button.

<asp:Panel ID="showMessagesPanel" CssClass="ModalWindowQur" style = "display:nonetext-align:centerheight:120%overflow:auto;" runat="server">                            <div style="max-height400pxoverflowautotext-alignleft;">                                <div class="popup_header">                                    Messages                                </div>                                <div class="popup_Body" style="padding-left:9%;">                                    <span>                                        <asp:GridView ID="messagesGridView" runat="server" DataKeyNames="Memo_Idx"                                             AutoGenerateColumns="False" ShowHeader="False" Width="60px" BackColor="#ffffff"                                             GridLines="None" OnRowDeleting="gv_MessagesRowDeleting"                                             OnSelectedIndexChanged="messagesGridView_SelectedIndexChanged">                                            <Columns>                                                <asp:TemplateField>                                                    <ItemTemplate>                                                        <asp:Panel CssClass="popupMenu" ID="PopupMenu2" runat="server">                                                            <div style="border1px outset whitepadding2pxz-index:5000">                                                                <div>                                                                    <asp:LinkButton ID="LinkButtonRepsDelete" runat="server" CommandName="Delete" Text="Delete" />                                                                    <br />                                                                    <asp:LinkButton ID="LinkButtonRepsSelect" runat="server" CommandName="Select" Text="View Rec." OnClientClick="openMessageForm"/>                                                                </div>                                                            </div>                                                        </asp:Panel>                                                                                                                                                                        <asp:Panel ID="Panel10" runat="server">                                                            <table style="width:700px;  table-layout:fixed;">                                                                                                                                <tr>                                                                                                                                        <td style="width:5%border-bottom1px solid #ddd;">                                                                        <asp:Label Font-Bold="true" ID="Label11" runat="server"                                                                             Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("Memo_Idx"))) %>' />                                                                    </td>                                                                    <td style="width:5%border-bottom1px solid #ddd; ">                                                                        <asp:Label Font-Bold="false" ID="Label5" runat="server"                                                                            Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("App_Code"))) %>' />                                                                    </td>                                                                    <td style="width:10%border-bottom1px solid #ddd; ">                                                                        <asp:Label Font-Bold="false" ID="Label6" runat="server"                                                                            Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("Mem_Rec_Numbr"))) %>' />                                                                    </td>                                                                    <td style="width:15%border-bottom1px solid #ddd; ">                                                                        <asp:Label Font-Bold="false" ID="Label7" runat="server"                                                                            Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("Mem_From"))) %>' />                                                                    </td>                                                                    <td style="width:15%border-bottom1px solid #ddd; ">                                                                        <asp:Label Font-Bold="false" ID="Label9" runat="server"                                                                            Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("Mem_To_Date2"))) %>' />                                                                    </td>                                                                    <td style="width:40%border-bottom1px solid #ddd; ">                                                                        <asp:Label Font-Bold="false" ID="Label10" runat="server"                                                                            Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("Mem_MSG"))) %>' />                                                                    </td>                                                                </tr>                                                            </table>                                                        </asp:Panel>                                                        <ajaxToolkit:HoverMenuExtender ID="hme12" runat="Server"                                                            HoverCssClass="popupHover"                                                            PopupControlID="PopupMenu2"                                                            PopupPosition="Left"                                                            TargetControlID="Panel10"                                                            PopDelay="25" />                                                    </ItemTemplate>                                                    <EditItemTemplate>                                                        <!-----Panel for displaying the update and cancel options for selected row------>                                                        <asp:Panel ID="panel_updateDelete" runat="server"                                                          CssClass="popupMenu">                                                            <div style="border1px outset whitepadding2pxz-index:5000">                                                                <asp:LinkButton ID="lnkUpdate"  CommandName="Update"                                                                 runat="server" Text="Update"></asp:LinkButton><br />                                                                <asp:LinkButton ID="lnkCanel" runat="server"                                                                 Text="Cancel" CommandName="Cancel"></asp:LinkButton>                                                            </div>                                                        </asp:Panel>                                                         <!-----Panel for displaying the TextBoxes in GridView------>                                                        <asp:Panel ID="panel_TB" runat="server" Style="width:90%;">                                                            <table  border="1" style="border-collapse:collapsewidth:100%;">                                                                <tr>                                                                    <td style="width:30%;"><asp:TextBox ID="txtName" style="width:auto;"                                                                     Text='<%#Eval("Qur_Name"%>' runat="server">                                                                    </asp:TextBox></td>                                                                    <td style="width:70%;"><asp:TextBox ID="txtDesc" style="width:auto;"                                                                    Text='<%#Eval("Qur_Desc"%>' runat="server">                                                                    </asp:TextBox></td>                                                                </tr>                                                            </table>                                                        </asp:Panel>                                                        <!-----HoverMenuExtender for displaying update and cancel options------>                                                        <ajaxToolkit:HoverMenuExtender ID="hme2" TargetControlID="panel_TB"                                                         PopupControlID="panel_updateDelete" PopupPosition="Right"                                                         HoverDelay="25" runat="server"></ajaxToolkit:HoverMenuExtender>                                                                                                        </EditItemTemplate>                                                </asp:TemplateField>                                            </Columns>                                        </asp:GridView>                                    </span>                                </div>                                <div class="popup_Buttons" style="padding-left:2%;">                                    <asp:Button ID="cancelEditButton" runat="server" Text="Done"  />                                </div>                            </div>                        </asp:Panel>                        <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender4" runat="server"                            TargetControlID="NotificationsImageButton"  CancelControlID="cancelEditButton" PopupControlID="showMessagesPanel" DropShadow="true" BackgroundCssClass="modalBackground">                            <Animations>                                <OnShown>                                    <FadeIn Duration=".4" Fps="20" />                                                </OnShown>                            </Animations>                        </ajaxToolkit:ModalPopupExtender>
protected void messagesGridView_SelectedIndexChanged(object sender, EventArgs e)        {//Load the query parameters to the main Queries screen, to allow edit selected fields and conditions            string mess_id = messagesGridView.SelectedValue.ToString();//get the query id in db            List<string> app_rec_selected = getApp_field(mess_id, "App_Code, Mem_Rec_Numbr");//get the SQL code for the selected query            //Response.Redirect(Request.Url.AbsoluteUri + "?TABLE=" + app_rec_selected[0] +            //                                        "&STATUS=4" +            //                                        "&ID=" + app_rec_selected[1]);            ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow",                                                                    "setTimeout(function(){ var mywin = window.open('DMS_Form.aspx?TABLE=" + app_rec_selected[0] +                                                    "&STATUS=4" +                                                    "&ID=" + app_rec_selected[1] +                                                                                                                                                                                    "','', 'scrollbars=yes, resizable=yes'); if (!mywin) {alert('A popup blocker was detected on the browser, Some functions might not work properly');} else { mywin.focus();}},1000);"true);            messagesGridView.SelectedIndex = -1;            updateMessageRead(mess_id);//update in the db that the message was read by the user (the user clicked the view rec. button                    }

I tried adding the following code but it doesn't seem to work:

foreach (GridViewRow row in messagesGridView.Rows)             {                 if (row.Cells[0].Text.ToString() == mess_id)                 {                     row.BackColor = System.Drawing.Color.Gray;                }             }


json ajax call in not firing

$
0
0

i have below code but its not calling mention action method when i put break point

 [HttpPost]
        public ActionResult subscribe(string values)
        {
            DataSet  ds = new DataSet ();
            ds = ts.SelectQueryDS ("select * from [TBL_USER] where username="+"'"+   Session["user"] + "'");

            int id= Convert.ToInt32(ds.Tables[0].Rows[0][0]);

            string[] valuesdb = values.Split(',');
            for (int i = 0; i < valuesdb.Length; i++)
            {
                valuesdb[i] = valuesdb[i].Trim();
                ts.IUD("insert into tbl_usergroup (userid,gid)values( " + id + "," + valuesdb[i] + ")");
            }
            DataSet ds1 = new DataSet();
            ds1 = ts.SelectQueryDS("select * from [TBL_USER] where username=" + "'" + Session["user"] + "'");

            int id2 = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            ds1 = ts.SelectQueryDS("select *   FROM [GroupChatSignalR].[dbo].[tbl_usergroup]  as [usergroup]  inner join tbl_group grp  on [usergroup].gid = grp.gid    where [usergroup].[Userid] =" + id2);
              return Json(ds1.Tables[0], JsonRequestBehavior.AllowGet);
        }
$.ajax({
                            url: '/Home/subscribe',
                            type: "POST",
                            data: { values: valueArray.toString() },
                            cache: false,
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (data) { alert(data); },
                            failure: function (errMsg) {
                                alert(errMsg);
                            }
                        });

File Upload Issues

$
0
0

Hi,

I have a C# webforms project that allows users to upload audio files to our system.

The majority of these uploads work fine but we're getting numerous errors every day and thought I'd ask here in case anyone has any ideas.

Warning emails containing the stack trace are sent to use automatically, so it's difficult to reproduce the errors ourselves.

Email #1

Error Url: https://www.ourwebsite.com/AjaxFileUploadHandler.axd?contextKey=%7BBA8BEDC8-B952-4d5d-8CC2-59FE922E2922%7D&controlID=cphPageContent_ModalAudio_AjaxFileUpload&fileId=AC0A81E2-6E02-B9B6-074C-22BD4FEF9293&fileName=example.MP3&chunked=true&firstChunk=false

Exception Type: System.Web.HttpException

Stack Trace

at System.Web.HttpBufferlessInputStream.Read(Byte[] buffer, Int32 offset, Int32 count) at AjaxControlToolkit.AjaxFileUploadHelper.ProcessStream(HttpContext context, Stream source, String fileId, String fileName, Boolean chunked, Boolean isFirstChunk, Boolean usePoll) at AjaxControlToolkit.AjaxFileUploadHelper.Process(HttpContext context) at AjaxControlToolkit.AjaxFileUploadHandler.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Email #2 (sent immediately after)

Error Url: https://www.ourwebsite.com/upload_audio?contextKey=%7BBA8BEDC8-B952-4d5d-8CC2-59FE922E2922%7D&controlID=cphPageContent_ModalAudio_AjaxFileUpload&done=1&guid=7051112B-A4DB-CB20-5546-360E0975A267&id=11234

Inner Exception Type: System.IndexOutOfRangeException

Inner Exception: There is no row at position 0.

Inner Source: System.Data

Inner Stack Trace

at System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex) at Controllers.AudioController.Update.UploadComplete(String thisId, String myWindow, String thatId, String filesize, String notes) at UserControls.ModalAudio.AjaxFileUpload_UploadComplete(Object sender, AjaxFileUploadEventArgs e) at AjaxControlToolkit.AjaxFileUpload.UploadRequestProcessor.XhrDone(String fileId) at AjaxControlToolkit.AjaxFileUpload.UploadRequestProcessor.ProcessRequest() at AjaxControlToolkit.AjaxFileUpload.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Stack Trace

at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.upload_audio_aspx.ProcessRequest(HttpContext context) in c:\windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\1e59898f\87cca7e3\App_Web_5saj2qnr.18.cs:line 0 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Has anyone seen this kind of issue before?

BalloonPopupExtender in TabControl and Update Panel

$
0
0

I have a master page that wraps the body of each page in an update panel.  The page I'm working on has a tab control with 2 tab panels.  The first tab panel has a balloon popup extender for an asp hyperlink control the shows/hides an asp panel control.  When navigating on this first tab, that extender works just fine.  When I switch to the second tab panel, which doesn't fire a postback because of the update panel, it initially loads ok, but as soon as I trigger any kind of postback (full or async) I get a javascript Error: Unable to get property 'click' of undefined or null reference

I assume this is because the target and display controls of the extender are no longer rendered because they reside on the first tab.  I'm wondering if there is a way I can disable or remove the click handlers for the popup extender when the tab changes using OnClientActiveTabChanged.  Or remove/disable the extender handlers all together.  I've tried a few different things (see below), but so far no luck.  If anyone has any idea how to get past this error, I'll be much obliged.

        function changeTab() {
            var extenderBehavior = $find("DisplayCustCredit");
            if ($find("<%=tcCreateCase.ClientID%>").get_activeTabIndex() != 0) {
                if (extenderBehavior._popupVisible != true) {
                    extenderBehavior.showPopup();
                }$removeHandler(extenderBehavior.get_element(), "click", extenderBehavior._clickHandler);$removeHandler(extenderBehavior.get_element(), "click", extenderBehavior._popupClickHandler);$removeHandler(extenderBehavior.get_element(), "click", extenderBehavior._displayOnClick);$removeHandler(extenderBehavior.get_element(), "click", extenderBehavior._bodyClickHandler);$removeHandler(extenderBehavior.get_element(), "click", extenderBehavior._popupElement);
                extenderBehavior.hidePopup();
            }
        }

Need a solution

$
0
0

Getting below error while change the dropdown or any button click on aspx page randomly, only on production server IIS and not recreated on local.

sys.webforms.pagerequestmanagerservererrorexception 500.

Following solutions not working for me !!!.

1.

1.
<script
type="text/javascript"language="javascript">Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);functionEndRequestHandler(sender, args){if(args.get_error()!=undefined){ args.set_errorHandled(true);}}</script>

2.<%@ Page ValidateRequest="false" %>

3.
<add key="aspnet:MaxHttpCollectionKeys" value="100000" />
</appSettings>
<system.web.extensions> <scripting> <scriptResourceHandler enableCompression="false" enableCaching="true"/> </scripting> </system.web.extensions>

How to add antiforgery token for AJAX call in MVC application

$
0
0

I'm trying mitigate CSRF issues for MVC application but facing issues while adding anti forgery token in following code in cshtml. Tried searching around but no concrete solution found.

Would appreciate any help..

 <td class="ignoreClick">
                    
                            @Ajax.ActionLink(
                                                "Delete","DeleteStudent","RqstProcessor",
                                                new
                                                {                                                    
                                                    id = current.key
                                                },
                                                new AjaxOptions
                                                {
                                                    AllowCache = false,                                                    
                                                    HttpMethod = "POST",
                                                    UpdateTargetId = "StudentList",
                                                    InsertionMode = InsertionMode.Replace,
                                                },
                                                new
                                                {
                                                    @class = "ignoreClick"
                                                }
                                             )
                    
                    </td>

Viewing all 5678 articles
Browse latest View live


Latest Images

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