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

ajax Calender with custom holidays disable

$
0
0

Hi ,

I have repeater and i want use calendar extender control or any  JQuery  Datepicker .

and i have holiday list in my database. with that i want to disable dates in calendar based on holidays list.

and please suggest which type of calendar should i use ajax extender or any jquery calendar?

please post script which can help to get my scenario.

Appreciate for Quick and Best Response


Ajax Control Toolkit

$
0
0

Sometimes I open VS Express 2013 and the Ajax Control Toolkit is gone from the toolbox. I reload it and all works ok. Bug????

AJAX to update partial section in ASP.NET page.

$
0
0
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="menu.aspx.cs" inherits="Portal.menu" %><%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title></title><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><link href="Content/bootstrap.css" rel="stylesheet" /><link href="Content/app.css" rel="stylesheet" /><script src="Scripts/jquery.js"></script><script src="Scripts/bootstrap.js"></script><script src="Scripts/app.js"></script><style type="text/css">
        .auto-style1 {
            width: 105px;
        }</style></head><body><form id="form1" runat="server"><div class="wrapper"><div class="header"><div class="main-frame"><div class="row"><div class="col-md-8"><img src="images/LOGO.png" alt="Logo" style="box-shadow: none; height: 90px; min-height: 90px; width: auto;" /></div><div class="col-md-4"><asp:ImageButton ID="imgPage1" runat="server" ImageUrl="~/Images/PageOne.png" OnClick="imgPage1_Click"/>&nbsp;<asp:ImageButton ID="imgPage2" runat="server" ImageUrl="~/Images/PageTwo.png" OnClick="imgPage2_Click"/>&nbsp;<asp:ImageButton ID="imgPage3" runat="server" ImageUrl="~/Images/PageThree.png" OnClick="imgPage3_Click"/>&nbsp;<asp:ImageButton ID="imgPage4" runat="server" ImageUrl="~/Images/PageFour.png" OnClick="imgPage4_Click"/></div>         </div></div></div><div class="main-content" id="mainContentBody"><iframe id='ifr' src="PageOne.html" style="overflow: hidden; height: 100%; width: 100%; position: absolute;"></iframe></div></div></form></body></html>

On my above Menu.aspx, there are four buttons: page1, page2, page3, page4  on the top right corner of the page. After that section, there is main content body which display  PageOne.html default when first loading. 

<div class="main-content" id="mainContentBody"><iframe id='ifr' src="PageOne.html" style="overflow: hidden; height: 100%; width: 100%; position: absolute;"></iframe></div>
I would like to use ASP.NET AJAX UpdatePanel with trigger to implement the following:

1. Click on Page2 button with replace source in iframe from PageOne.html to PageTwo.html
2. Click on Page3 button with display the content of PageThree.aspx
3. Click on page4 button with display the content of PageFour.aspx and so on.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Portal
{
    public partial class menu : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void imgPage1_Click(object sender, ImageClickEventArgs e)
        {

        }

        protected void imgPage2_Click(object sender, ImageClickEventArgs e)
        {

        }

        protected void imgPage3_Click(object sender, ImageClickEventArgs e)
        {

        }

        protected void imgPage4_Click(object sender, ImageClickEventArgs e)
        {

        }
    }
}
I am not sure how to make all completed codes. Any codes in javascript, jQuery and ASP.NET C# guru, please help. Thanks in advance.

Comment Like With Update Panel

$
0
0

Hi everyone. I want to comments and this comments users will like but with in update panel. I have problem click buton like number rising in database. But in page dont rise. Can anone help me please.

Update Panel below.

<asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><asp:LinkButton ID="lnkbegen" data-toggle="tooltip" data-placement="bottom" title="Beğendim" runat="server" OnClick="lnkbegen_Click"><i class="fa fa-futbol-o"></i></asp:LinkButton><br /><span class="count-icon"><span class="count" style="right: 5px;"><%#Eval("Begen") %></span></span></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="lnkbegen" EventName="Click"    />                </Triggers></asp:UpdatePanel>

Below LinkButton Click Event

 using (TeknikTraktorEntities tr = new TeknikTraktorEntities())
            {               

                Yorumlar y = tr.Yorumlar.SingleOrDefault(x => x.ID == 1);

                y.Begen ++;
                y.Begenme ++;
                tr.SaveChanges();
            }

Why doesn't ajaxModalExtender hide ?

$
0
0

i have used AjaxModalExtender, it works but problem is that when it appears then it

<asp:image ID="ImageLetterCopy"  style="max-width: 100%;max-height: 100%"   runat="server" />


doesn't hide anyway. I want to hide it, how can I do it ? 

<asp:HiddenField ID="hdnField1" runat="server" /><asp:ModalPopupExtender ID="mdlMessageBox" BackgroundCssClass="modalBackground" runat="server" TargetControlID="hdnField1"
                    PopupControlID="ImageLetterCopy"></asp:ModalPopupExtender>

i just want to hide it when some one clicks anywhere on page or any other simple way.

updatepanel timer every one second

$
0
0

hi,

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

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        XDocument document = XDocument.Load("http://localhost:56466/1000217859.xml");


        var test = from t1 in document.Descendants("path")
                     where t1.Parent.Element("path").Element("name") != null
                   select t1.Parent.Element("path").Element("name");

     //   IEnumerable<XElement> list1 = document.Root.Descendants("events");


        GridView1.DataSource = test;
        GridView1.DataBind();
    }
    protected void Unnamed_Tick(object sender, EventArgs e)
    {
        XDocument document = XDocument.Load("http://localhost:56466/1000217859.xml");


        var test = from t1 in document.Descendants("path")
                   where t1.Parent.Element("path").Element("name") != null
                   select t1.Parent.Element("path").Element("name");

        GridView1.DataSource = test;
        GridView1.DataBind();
    }
}

My code working...

I want to ask you how to use timer every one second.

Before:


after:



I need every one second to show first picture. Marked text.
Thanks.


Why does a popup appear at bottom instead of being in center ?

$
0
0

I have an image inside ajax modal extender. It appears successfully when a button is clicked inside gridview but the image is scrolled to the right bottom of page by default and only comes to center when i press down arrow on keyboard. Why ? How to put it in center by default ?

<asp:ModalPopupExtender ID="mdlMessageBox" BackgroundCssClass="modalBackground" runat="server" TargetControlID="hdnField1"<asp:ImageButton ID="ImageLetterCopy" OnClick="ImageLetterCopy_Click"  style="max-width: 100%;max-height: 100%"   runat="server" />

CSS

<styletype="text/css">.modalBackground {background-color: Black;filter: alpha(opacity=90);opacity:0.8;}.modalPopup {background-color: whitesmoke;border-width:0px;border-style: solid;border-color: black;padding-top:10px;padding-left:10px;padding-right:10px;/*width: 600px;
            height: 280px;*/}</style>

popup extender - showing the panel in the second record!

$
0
0

Hi,

I have a panel in the gridview. After clicking on a button(on the first record)  i am getting the popup panel displayed but if i click the button (which is in the second record), I am getting the pannel displayed in the same record area and not as a popup! 

Can someone help with this?

protected void showit_Click(object sender, EventArgs e)
    {

        //Find the button controls from sender
        Button btn = (Button)sender;

        //Get the row that contains this button
        GridViewRow row = (GridViewRow)btn.NamingContainer;

        //Find the panel control
        Panel panel1 = row.FindControl("Panel1") as Panel;
        panel1.Visible = true;
    }

it is really getting out of hand! i still don't know why and how the following is happening!

first record will show the panel in the popup but the second record will show the pannel in the same area of the gridview!!!!!!


Update panel - multiview - controls not getting fired

$
0
0

HI,

I am using ASP.NET 4.0 and i have placed a update panel. The page has 2 views. 

I have button and dropdown events in the views. I have used the below code:

<asp:UpdatePanel ID="upd1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true"><ContentTemplate><asp:MultiView ID="Mul1" runat="server" ActiveViewIndex="0"><asp:View ID="View1" runat="server"><table><tr> <td><asp:ImageButton ID="Img1" runat="server" ImageUrl="/images/Submitn.png" OnClick="Img1_Click" /></td></tr><tr><td ><asp:DropDownList ID="ddl1" runat="server" AutoPostBack="true"                                        OnSelectedIndexChanged="ddl1_SelectedIndexChanged"></asp:DropDownList></td></tr></asp:View><asp:View ID="View2" runat="server"></asp:View></asp:MultiView></ContentTemplate></asp:UpdatePanel>

The button events and dropdown events are not getting fired. If I remove the update panel, then events are firing.

How to fix this?

Thanks

AJAX webmethod declaration in VS 2015

$
0
0

I have recently upgraded to VS 2015, and I now have trouble with declaring AJAX webmethods using VB, specifically the underscore.

I have this declaration:

Public Class AJAX
    Inherits System.Web.UI.Page<System.Web.Services.WebMethod()>
    Public Shared Sub opdaterVideoStat(ByVal playlist_id As Integer)
        TV2BGlobal.opdaterVideoStatistik(playlist_id)
    End Sub
End Class

As I understand it there MUST be an underscore after the webMethod()> for this to Work, but visual studio 2015 automatically removes it every time I try to insert it.

And I cannot get the AJAX functionality to work.

I have another application which has been ported from VS 2012 to VS 2015, and in that app the underscore stays, and the AJAX functionality works.

Whats up with this?

Update Panel in Repater Textbox Blank.

$
0
0

Hi, I entered Textbox but When I click LinkButton is Textbox blank coming. Why ? How can I do.

İmportant = This example Update Panel and in Repater.

Html Code below.

<div class="panel panel-default"><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always"><ContentTemplate><asp:Repeater ID="rptyorumlar" runat="server" ClientIDMode="AutoID"><ItemTemplate><div class="panel-body"><div class="col-md-12 nosag nosol"><div class="col-md-6 text-left nosag nosol"><div class="comment-user"><i class="fa fa-user"></i>&nbsp;<b><%#Eval("UserID") %></b></div><time><i class="fa fa-clock-o"></i>&nbsp;<span style="color: #ddd;"><%#Eval("Tarih") %></span></time></div><div class="col-md-6 text-right nosag nosol"><div class="comment-user"><i class="fa fa-comment-o"></i>&nbsp;<b><%#Eval("ID") %></b></div></div></div><div class="comment-post"><p><%#Eval("Yorum") %></p></div><div class="col-md-6 nosag nosol"><div class="col-md-3 nosag nosol"><asp:Label ID="lblId" runat="server" Text='<%#Eval("ID") %>' Visible="false" /><span style="font-size: 19px;"><asp:LinkButton ID="lnkbegen" data-toggle="tooltip" data-placement="bottom" title="Beğendim" runat="server" OnClick="lnkbegen_Click"><i class="fa fa-futbol-o"></i> </asp:LinkButton><span class="count-icon"><span class="count" style="right: 5px;"><%#Eval("Begen") %></span></span></span></div><div class="col-md-3 nosag nosol"><asp:Label ID="lblad" runat="server" Text='<%#Eval("ID") %>' Visible="false" /><span style="font-size: 19px;"><asp:LinkButton ID="lnkbegenme" class='<%#Eval("ID") %>' data-toggle="tooltip" data-placement="bottom" title="Beğenmedim" runat="server" OnClick="lnkbegenme_Click"><i class="fa fa-heartbeat"></i></asp:LinkButton><span class="count-icon"><span class="count" style="right: 5px;"><%#Eval("Begenme") %></span></span></span></div></div><div class="col-md-6 nosag nosol text-right"><span style="font-size: 19px;"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-bug"></i></a><ul class="dropdown-menu" style="border: 1px solid; border-color: #D5D5C9; padding: 5px; margin-top: -85px;"><div><div class="form-group"><asp:TextBox ID="txtsikayet" Rows="2" CssClass="form-control" runat="server"></asp:TextBox></div><div class="form-group" style="padding-top: 0px;"><asp:LinkButton ID="lnksikayetet" CssClass="btn btn-info btn-block" runat="server" OnClick="lnksikayetet_Click">Şikayet</asp:LinkButton></div></div></ul></span></div></div><hr /></ItemTemplate></asp:Repeater></ContentTemplate></asp:UpdatePanel></div>

Link button code behind.

 protected void lnksikayetet_Click(object sender, EventArgs e)
        {


            LinkButton lnkk = sender as LinkButton;

            int id = int.Parse(((lnkk.NamingContainer).FindControl("lblid") as Label).Text);
            string sikayet = (lnkk.NamingContainer.FindControl("txtsikayet") as TextBox).Text;                


            using (Entities tri = new Entities())
            {
                Sikayet sk = new Sikayet
                {

                    Sikayet1 = sikayet,
                    Tarih = DateTime.Now,
                    YorumID = id,
                    UserID = 3

                };

                tri.Sikayet.Add(sk);
                tri.SaveChanges();
                Response.Write("<script LANGUAGE='JavaScript' >alert('Kayıt Eklenmiştir...')</script>");

            }
        }

modalpopup extender buttons do nothing

$
0
0

I have a gridview that users can add items to.  The Add Bike button opens a modal popup that they can enter values in but when you press the add bike button the popup closes and the onclick event for the button never fires. Debugging it, the break on that point is not touched. ASPX:

<asp:Panel ID="pnlbikelist" runat="server" CssClass="modalPanel" Width="265" style="display:none;"><table ><tr><td><asp:Label ID="lblyr" runat="server" Text="Year:" Width="100"></asp:Label></td><td><asp:TextBox ID="tbyear" runat="server" Width="125" /></td></tr><tr><td><asp:Label ID="lblmk" runat="server" Text="Make:" Width="100"></asp:Label></td><td> <asp:TextBox ID="tbmake" runat="server" Width="125" /></td></tr><tr><td> <asp:Label ID="lblmdl" runat="server" Text="Model:" Width="100"></asp:Label></td><td> <asp:TextBox ID="tbmodel" runat="server" Width="125" /></td></tr><tr><td> <asp:Label ID="lbltgyp" runat="server" Text="Type:" Width="100"></asp:Label></td><td> <asp:DropDownList ID="ddltype" runat="server" DataSourceID="dsbiketype" DataTextField="biketype" DataValueField="biketypeid"></asp:DropDownList><asp:SqlDataSource ID="dsbiketype" runat="server" ConnectionString="<%$ ConnectionStrings:BDUCConnectionString %>" SelectCommand="UM_biketypes" SelectCommandType="StoredProcedure"></asp:SqlDataSource></td></tr><tr><td ><asp:Label ID="lbcmt" runat="server" Text="Comment:" Width="100"></asp:Label></td><td> <asp:TextBox ID="tbdesc" runat="server" Width="125" /></td></tr><tr><td colspan="2" ><asp:Button ID="btnsavebikes" runat="server" Enabled="true" Text="Save" OnClick="btnsavebikes_Click" CommandName="savebike" CommandArgument="Session[RID]" OnCommand="btnsavebikes_Command" Width="42px" />&nbsp;<asp:Button ID="btncan" runat="server" Text="Cancel" OnClick="btncan_Click" />                                                                                                                                                                                                                                                                                                                                                                                                                                                 </td></tr></table></asp:Panel><asp:Button ID="Button2" runat="server" Text="Button" style="display:none;" /><ajaxToolkit:ModalPopupExtender ID="pnlbikelist_ModalPopupExtender" runat="server" 
            BehaviorID="pnlbikelist_ModalPopupExtender" TargetControlID="Button2" PopupControlID="pnlbikelist" OkControlID="btnsavebikes" CancelControlID="btncan"></ajaxToolkit:ModalPopupExtender>

C#:

  protected void btnsavebikes_Click(object sender, System.EventArgs e)
    {
        utility ut = new utility();
        ut.addbike(rid, tbyear.Text, tbmake.Text, tbmodel.Text, tbdesc.Text, Convert.ToInt32(ddltype.SelectedValue));
    }

the ut.addbike method works if run alone, the problem is the popup closes without ever running it.

Ajax quits working after login, ScriptManager?

$
0
0

I just copied my website over to a new solution.

I got everything up and running, but when I login, my hover menus stop working.  I checked and when a user is not logged in, ajax is working.

I'm thinking it has something to do with the Master Page ScriptManager.  Also, I notice my solution doesn't recognize System.Web.UI.  I have to import it for it to work.

I checked my assemblies and System.Web.Extentions is there.

Here is my master page markup and code:

<%@ Master Language="VB" AutoEventWireup="true" CodeBehind="Site.master.vb" Inherits="hsc.SiteMaster" %><%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxtoolkit" %><%@ Import Namespace="toc" %><%@ Import Namespace="Microsoft.AspNet.Identity" %><!DOCTYPE html><html lang="en"><head runat="server"><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><asp:PlaceHolder runat="server"><%: Scripts.Render("~/bundles/modernizr") %></asp:PlaceHolder><webopt:bundlereference runat="server" path="~/Content/css" /><link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" /></head><body><form runat="server"><asp:ScriptManager runat="server"><Scripts><%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%><%--Framework Scripts--%><asp:ScriptReference Name="MsAjaxBundle" /><asp:ScriptReference Name="jquery" /><asp:ScriptReference Name="bootstrap" /><asp:ScriptReference Name="respond" /><asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" /><asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" /><asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" /><asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" /><asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" /><asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" /><asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" /><asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" /><asp:ScriptReference Name="WebFormsBundle" /><%--Site Scripts--%></Scripts></asp:ScriptManager><div class="navbar navbar-inverse navbar-fixed-top"><div class="container"><div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand" runat="server" href="~/">HSC</a></div><div class="navbar-collapse collapse"><ul class="nav navbar-nav"><li><a runat="server" href="~/Home">Home</a></li><li><a runat="server" href="~/Profiles">Profiles</a></li><li><a runat="server" href="~/Contact">Contact</a></li><li><a runat="server" href="~/About">About</a></li><li><div class="sMDate"><asp:Label ID="Label126" runat="server" ForeColor="Silver"></asp:Label></div></li></ul><asp:LoginView runat="server" id="LoginView1" ViewStateMode="Disabled"><AnonymousTemplate><ul class="nav navbar-nav navbar-right"><li><a runat="server" href="~/Account/Register" style="color: red;">Register</a></li><li><a runat="server" href="~/Account/Login" style="color: green;">Log in</a></li><li><asp:ImageButton ID="Image3" runat="server" AlternateText="IMAGE" PostBackUrl="~/Account/Login.aspx" Class="sMImg" Height="35px" ImageUrl='~/Images/tocmodel2.gif' ToolTip="Sign In!" Width="35px" ValidationGroup="reggate" /></li></ul></AnonymousTemplate><LoggedInTemplate><ul class="nav navbar-nav navbar-right"><li><a runat="server" href="~/Account/Manage" title="Manage your account" style="color:green">Hello, <%: Context.User.Identity.GetUserName()  %>!</a></li><li><asp:GridView ID="GridView2" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="Id,UserName" DataSourceID="SqlDataSource2" GridLines="None" PageSize="1" ShowHeader="False"><Columns><asp:TemplateField HeaderText="Your Settings" SortExpression="UserName"><ItemTemplate><li><asp:Image ID="Image3" runat="server" AlternateText='<%# Bind("lastName")%>' CssClass="sMImg" Enabled='<%# Bind("ImgID") %>' 
                                            Height="35px" ImageUrl='<%# FormatURL11(DataBinder.Eval(Container.DataItem, "ImgID")) %>' onerror="this.src='images/tocmodel2.gif'" 
                                            ToolTip='<%# Bind("firstName")%>' Width="35" /></li><ajaxToolkit:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="Image3" PopupControlID="Panel1" PopupPosition="Left" OffsetY="-6" OffsetX="-5"></ajaxToolkit:HoverMenuExtender><asp:Panel ID="Panel1" runat="server" CssClass="SMHover"><li><asp:HyperLink ID="HyperLink6" runat="server" Text="Profile" NavigateUrl='<%# Eval("Id", "profile.aspx?Id={0} ") %>'></asp:HyperLink><a runat="server" href="~/Account/Settings" title="Manage your settings" style="color:green;width:75px;">Settings</a><asp:LoginStatus runat="server" LogoutAction="Redirect" LogoutText="Exit" LogoutPageUrl="~/" OnLoggingOut="Unnamed_LoggingOut" /></li></asp:Panel></ItemTemplate></asp:TemplateField></Columns><PagerSettings Visible="False" /></asp:GridView><asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" 
    DeleteCommand="DELETE FROM [AspNetUsers] WHERE [Id] = @Id AND [UserName] = @UserName" 
    InsertCommand="
      INSERT INTO [AspNetUsers] ([URL], [firstName], [UserName]) VALUES (@firstName, @URL, @UserName)" 
    SelectCommand="SELECT Id, firstName, lastName, Quote, Sign, URL, zCode, UserName, Image, ImgID FROM dbo.AspNetUsers WHERE (UserName = @UserName)" 
    UpdateCommand="
      UPDATE [AspNetUsers] SET [firstName] = @firstName, [lastName] = @lastName, 
= @Quote, [Sign] = @Sign, [URL] = @URL, [zCode] = @zCode, [UserName] = @UserName WHERE [Id] = @Id AND Username = @UserName" OnDeleting="SqlDataSource1_Deleting" OnInserting="SqlDataSource1_Inserting" OnSelecting="SqlDataSource1_Selecting" OnUpdating="SqlDataSource1_Updating"><DeleteParameters><asp:Parameter Name="Id" Type="String" /><asp:Parameter Name="UserName" Type="String" /></DeleteParameters><InsertParameters><asp:Parameter Name="firstName" /><asp:Parameter Name="URL" Type="String" /><asp:Parameter Name="UserName" Type="String" /></InsertParameters><SelectParameters><asp:Parameter Name="UserName" Type="String" /></SelectParameters><UpdateParameters><asp:Parameter Name="firstName" Type="String" /><asp:Parameter Name="lastName" Type="String" /><asp:Parameter Name="Quote" Type="String" /><asp:Parameter Name="Sign" Type="String" /><asp:Parameter Name="URL" Type="String" /><asp:Parameter Name="zCode" Type="String" /><asp:Parameter Name="UserName" Type="String" /><asp:Parameter Name="Id" Type="String" /></UpdateParameters></asp:SqlDataSource></li></ul></LoggedInTemplate></asp:LoginView></div></div></div><div class="container body-content"><asp:ContentPlaceHolder ID="MainContent" runat="server"></asp:ContentPlaceHolder><hr /><footer class="tocCFooter"><p>&copy; <%: DateTime.Now.Year %> - GSpotProd</p></footer></div></form></body></html>
Imports Microsoft.AspNet.Identity
Imports System.Web.Providers.Entities
Imports System.Data.Common

Public Class SiteMaster
    Inherits MasterPage
    Private Const AntiXsrfTokenKey As String = "__AntiXsrfToken"
    Private Const AntiXsrfUserNameKey As String = "__AntiXsrfUserName"
    Private _antiXsrfTokenValue As String

    Protected Sub Page_Init(sender As Object, e As EventArgs)
        ' The code below helps to protect against XSRF attacks
        Dim requestCookie = Request.Cookies(AntiXsrfTokenKey)
        Dim requestCookieGuidValue As Guid
        If requestCookie IsNot Nothing AndAlso Guid.TryParse(requestCookie.Value, requestCookieGuidValue) Then
            ' Use the Anti-XSRF token from the cookie
            _antiXsrfTokenValue = requestCookie.Value
            Page.ViewStateUserKey = _antiXsrfTokenValue
        Else
            ' Generate a new Anti-XSRF token and save to the cookie
            _antiXsrfTokenValue = Guid.NewGuid().ToString("N")
            Page.ViewStateUserKey = _antiXsrfTokenValue

            Dim responseCookie = New HttpCookie(AntiXsrfTokenKey) With { _
                 .HttpOnly = True, _
                 .Value = _antiXsrfTokenValue _
            }
            If FormsAuthentication.RequireSSL AndAlso Request.IsSecureConnection Then
                responseCookie.Secure = True
            End If
            Response.Cookies.[Set](responseCookie)
        End If

        AddHandler Page.PreLoad, AddressOf master_Page_PreLoad
    End Sub

    Protected Sub master_Page_PreLoad(sender As Object, e As EventArgs)
        If Not IsPostBack Then
            ' Set Anti-XSRF token
            ViewState(AntiXsrfTokenKey) = Page.ViewStateUserKey
            ViewState(AntiXsrfUserNameKey) = If(Context.User.Identity.Name, [String].Empty)
        Else
            ' Validate the Anti-XSRF token
            If DirectCast(ViewState(AntiXsrfTokenKey), String) <> _antiXsrfTokenValue OrElse DirectCast(ViewState(AntiXsrfUserNameKey), String) <> (If(Context.User.Identity.Name, [String].Empty)) Then
                Throw New InvalidOperationException("Validation of Anti-XSRF token failed.")
            End If
        End If
    End Sub

    Protected Sub SqlDataSource1_Selecting(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)
        AssignUserName(e.Command.Parameters)
    End Sub

    Protected Sub SqlDataSource1_Inserting(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs)
        AssignUserName(e.Command.Parameters)
    End Sub

    Protected Sub SqlDataSource1_Updating(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs)
        AssignUserName(e.Command.Parameters)
    End Sub

    Protected Sub SqlDataSource1_Deleting(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs)
        AssignUserName(e.Command.Parameters)
    End Sub

    Private Sub AssignUserName(parameters As DbParameterCollection)
        parameters("@UserName").Value = HttpContext.Current.User.Identity.Name
    End Sub

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

        If (HttpContext.Current.User.Identity.IsAuthenticated) Then
            Dim User As String = HttpContext.Current.User.Identity.Name
        End If

        'Dim UO As System.Web.UI.WebControls.Label = DirectCast(LoginView1.FindControl("UO"), System.Web.UI.WebControls.Label)

        'Put user code to initialize the page here


        Dim timeZoneInfo__1 As TimeZoneInfo
        Dim dateTime__2 As DateTime
        'Set the time zone information to US Mountain Standard Time 
        timeZoneInfo__1 = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time")
        'Get date and time in US Mountain Standard Time 
        dateTime__2 = TimeZoneInfo.ConvertTime(DateTime.Now, timeZoneInfo__1)
        'Print out the date and time
        Label126.Text = (dateTime__2.ToString("MM/dd/yy hh:mm:ss tt"))
    End Sub

    'Public Function FormatDate(ByVal input As DateTime) As Object
    '   Return [String].Format("{0:MM/dd/yy}", input)
    'End Function

    Protected Sub Unnamed_LoggingOut(sender As Object, e As LoginCancelEventArgs)
        Context.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie)
    End Sub

    Function FormatURL11(ByVal strArgument As String) As String
        Return ("getImage.aspx?ImgID=" & strArgument)
    End Function

End Class



ModalPopupExtender called from UpdatePanel problem

$
0
0

Hello.

I'm having problem with calling modalPopupExtender control from updatePanel control.

I have modal popup extender as a custom control MessageBox, which I can register on any webform or usercontrol, then call it from code behind any time I need and I also can put events on buttons on this MessageBox, which are handled on the webfrom/control, from which Im calling the messagebox.

MessageBox.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MessageBox.ascx.cs" Inherits="Controls_MessageBox_MessageBox" %><ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" 
    TargetControlID="Panel1"
    PopupControlID="Panel1"
    BackgroundCssClass="modalBackground"
    DropShadow="true" /><asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" style="display: none;" Width="400px" DefaultButton="SeButton"><asp:Label ID="lblTitle" runat="server" CssClass="modalPopupTitle" style="font-family: Verdana; font-size: 15px; font-weight: bold;" Width="100%" Text="<% $ Resources:SystemMessage, String1 %>"></asp:Label><br /><br /><asp:Table ID="tblTextArea" runat="server" Width="100%"><asp:TableRow ><asp:TableCell Width="34px" Height="32px"><asp:Image ID="imgMessage" runat="server" Width="32px" Height="32px" /></asp:TableCell><asp:TableCell Height="32px"><asp:Panel ID="pnlMessage" runat="server" Width="350px"><asp:Label ID="lblMessage" runat="server" style="font-family: Verdana; font-size: 14px;" CssClass="modalPopupText"></asp:Label></asp:Panel></asp:TableCell></asp:TableRow><asp:TableRow><asp:TableCell ColumnSpan="2">&nbsp;</asp:TableCell></asp:TableRow><asp:TableRow HorizontalAlign="Center"><asp:TableCell ColumnSpan="2"><asp:Button ID="aButton" runat="server" Text="aButton" OnClick="aButton_Click" Width="90px" />                </asp:TableCell></asp:TableRow></asp:Table></asp:Panel><script type="text/javascript">
    function fnClickA(sender, e) {
        __doPostBack(sender, e);
    }</script>

MessageBox.ascx.cs

using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Controls_MessageBox_MessageBox : System.Web.UI.UserControl
{
    #region system_methods

    protected void Page_Load(object sender, EventArgs e)
    {
        aButton.OnClientClick = String.Format("fnClickA('{0}','{1}')", aButton.UniqueID, "");
    }

    public void aButton_Click(object sender, EventArgs e)
    {
        OnaButtonPressed(e);
    }

    #endregion

    #region user_methods

    /// <summary>
    /// Show message on modal dialog.
    /// </summary>
    /// <param name="Message">Set string to show on dialog.</param>
    /// <param name="ImagePath">Set image path using GetPathOfMBImage from GlobalConstants class.</param>
    public void ShowMessage(String Message, String ImagePath)
    {
        lblMessage.Text = Message;
        imgMessage.ImageUrl = ImagePath;
        SetHeight(Message);
        ModalPopupExtender1.Show();
    }

    /// <summary>
    /// Set panel height and show/hide vertical scroolbar.
    /// </summary>
    /// <param name="Message">String to show on dialog.</param>
    private void SetHeight(String Message)
    {
        if (Message.Length > 700)
        {
            pnlMessage.Height = 420;
            pnlMessage.ScrollBars = ScrollBars.Vertical;
        }
        else
        {
            pnlMessage.ScrollBars = ScrollBars.None;
        }
    }

    /// <summary>
    /// Hide modal dialog and clear all text on it.
    /// </summary>
    public void HideMB()
    {
        lblMessage.Text = String.Empty;
        ModalPopupExtender1.Hide();
    }

    #endregion

    #region custom_event

    public delegate void aButtonPressedHandler(object sender, EventArgs args);
    public event aButtonPressedHandler aButtonPressed;
    protected virtual void OnaButtonPressed(EventArgs e)
    {
        if (aButtonPressed != null)
            aButtonPressed(VujeButton, e);
    }

    #endregion
}

The problem is, that I have a main page, which has a page control on it. Every sub-page on this page control is a custom user control. On one of this custom user control I'm calling this message box from code behind. I tried to putting this whole pagecontrol inside of Update panel, to not causing page refreshes everytime. But when I do, Im able to call MessageBox control isntance, but they appear not responding to the button events on them.

Example of calling the message box from the control:

customControl.ascx

<%@ Register Src="~/Controls/MessageBox/MessageBox.ascx" TagName="OkMessageBox" TagPrefix="un" %>

... other code ...

<un:OkMessageBox ID="okMB" runat="server" Visible="false" />

customControl.ascx.cs

... some code ...

protected void Page_Load(object sender, EventArgs e)
    {
        okMB.aButtonPressed += new Controls_MessageBox_MessageBox_aButtonPressedHandler.aButtonPressedHandler(okMB_aButtonPressed);

... other code ....
}

... other code ...

some method
{
okMB.Visible = true;
        okMB.ShowMessage("Text", "Path to img");

}

... other code ....

void okMB_aButtonPressed(object sender, EventArgs args)
    {
        ... some code ...
    }

mainpage.aspx

(script manager is on master page for thsi main page)

... some code ...

<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server"><ContentTemplate>

... page control with custom control on every sub-page ....


    </ContentTemplate></asp:UpdatePanel>

... other code ...


The problem is, that the messagebox appears, but the button aButton event is not fired and no postback is done and whole page is practically dead and not responsive.

Please, is there some workaround ?

Or is it posible, to have this messagebox control and use it somehow FROM a UpdatePanel ?

( I was editing our existing code and left only one button there and renamed it to 'aButton', so if there are some typing errors, its not relevant).

I'm thankfull for every suggestion.

Modal Popup in .Net to load URL

$
0
0

I need to open a data entry page in a modal popup and after submitting form keep the popup open so user can add multiple entries.

Once user is done with entries and closes popup, need to refresh parent page.  Used to use window.parent.location.reload() but this no longer works.

browser: ie9

 


Updatepanel in masterpage, trigger the FileUpload in a child webform-Help

$
0
0

I try to pass the postbacktrigger in the child webform using this code:

protected void Page_Load(object sender, EventArgs e)
{
//For file upload to be triggers
UpdatePanel updatepanel = Page.Master.FindControl("UpdatePanel1") as UpdatePanel;
UpdatePanelControlTrigger trigger = new PostBackTrigger();
trigger.ControlID = FileUpload1.UniqueID;
updatepanel.Triggers.Add(trigger);
}

But I got this error:
"Control with ID 'FileUpload1' being registered through RegisterAsyncPostBackControl
or RegisterPostBackControl must implement either INamingContainer, IPostBackDataHandler,
or IPostBackEventHandler."

Masterpage design source:
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

<asp:UpdateProgress runat="server">
<ProgressTemplate>
<div class="upmodal">
<div class="upcenter">
Please wait... processing...
<img alt="" src="Loading.GIF" />
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>

<asp:UpdatePanel ID ="UpdatePanel1" runat="server" UpdateMode ="Conditional" >
<Triggers >
<asp:AsyncPostBackTrigger ControlID ="Button1" />
</Triggers>
<ContentTemplate>

<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>

</div>
</form>


Child Webform Design source:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:FileUpload ID="FileUpload1" runat ="server" AllowMultiple ="true" />
<asp:Button ID ="btnUpload" Text ="Upload it" runat ="server" OnClick ="Click_Upload" />
<asp:Label ID="Label1" runat ="server" ></asp:Label>
</asp:Content>

Please Help Thanks

ModalPopupExtender does not work with DataList

$
0
0

Hi,

I have a DataList in which I am displaying images from the database. I have added a ModalPopupExtender within the ItemTemplate of the DataList to open the larger version of the image I am clicking on.

But the only image that works is the first one. When I click on it, the popup opens fine. But none of the other images open the popup.

My aspx code is below:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="frmPhotos.aspx.vb" Inherits="AJAXWebApp.frmPhotos" %><%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title></title><link href="cssBackground.css" rel="stylesheet" /><script type="text/javascript">
        function pageLoad() {
            var mpe = $find("MPE");
            mpe.add_shown(onShown);
        }
        function onShown() {
            var background = $find("MPE")._backgroundElement;
            background.onclick = function () {$find("MPE").hide();

            }
        }
        function modalPopupLoad() {
            var hovermenu = $find("HME");
            hovermenu._hoverBehavior._hoverElement.style.visibility = "hidden";
        }</script></head><body><form id="form1" runat="server"><div style="align-content:center"><asp:ScriptManager ID ="scriptMgr1" runat="server"></asp:ScriptManager><asp:UpdatePanel ID="updatePanelMain" runat="server"><ContentTemplate><asp:DataList ID ="dlPhotos" runat="server" RepeatColumns="6" RepeatDirection="Horizontal" Width="60%"><ItemTemplate><asp:ImageButton ImageUrl='<%#Eval("FileName")%>' runat="server" ID="img" Height="125" OnClick="thumbnail_Click" /><asp:Panel ID ="pnlMainImage" runat="server" Height="150" Width="150" HorizontalAlign="Center" style="display:none"><asp:Image ID ="imgMain" runat="server" Height ="90%" ImageUrl='<%#Eval("FileNameMain")%>' /></asp:Panel><cc1:modalpopupextender id="ModalPopupExtender1" runat="server" BehaviorID="MPE"
	                        targetcontrolid="img" popupcontrolid="pnlMainImage" 
                            drag="true" backgroundcssclass="ModalPopupBG"><Animations><OnShown><Sequence><Parallel><Resize height="700" width="900"></Resize><Move Horizontal="-300" Vertical="-300"></Move></Parallel></Sequence></OnShown></Animations></cc1:modalpopupextender></ItemTemplate></asp:DataList></ContentTemplate></asp:UpdatePanel></div></form></body></html>

Am I missing something?

Gridview UpdatePanel Paging Works, but Not LinkButton

$
0
0

Hello, I have a gridview in an update panel with paging controls.  Inside the gridview, I have a template item with a linkbutton with the command "next".

On deployment, the paging links work with the update panel, but not the linkbutton.

The baffling part is I have another application with the identical page setup, and the update panel works fine with both controls.  Both applications have the triggers setup in the update panel.

I've read that I have to loop thru the rows to find the control, however, why?  The other application is working fine by just dropping the gridview in the update panel and selecting the trigger.  (gridview: PageIndexChanged)

<ItemTemplate><iframe id="I2" height="70" name="I1" src="gvAd.html" style="border-style:none;" width="295"></iframe><br /><asp:Label ID="Label1" runat="server" Text='<%# Bind("firstName")%>'></asp:Label><br /><asp:LinkButton ID="LinkButton2" runat="server" BorderStyle="None" CommandArgument="Next" CommandName="Page"><asp:Image ID="Image2" runat="server" ImageUrl='<%# FormatURL11(DataBinder.Eval(Container.DataItem, "ImgID"))%>' onerror="this.src='images/hsc_splash.gif'"
                                                ToolTip='<%# Bind("firstName")%>' CssClass="tocimg" BorderStyle="None" Height="335px" Width="335px" /></asp:LinkButton><br /><asp:Label ID="Label3" runat="server" Text='<%# Bind("zCode")%>'></asp:Label></ItemTemplate>
<Triggers><asp:AsyncPostBackTrigger ControlID="GridView1" EventName="PageIndexChanged" /></Triggers>

Textbox in separate updatepanel flickering

$
0
0

I've been searching for a solution with no luck.

I use Ajax update panels frequently for rich postbacks with my database.

but even though I have separate update panels set to "conditional", the textboxes still "flicker" or lose focus during a postback?

I don't want any text boxes flickering when I post a message. 

I won't post any code because all my code is working and I have no errors, but I'm using Ajax 3.5 and net 3.5. 

This must be a notorious issue that I haven't found a solution for.

Thank you for any help or insight!

David

BC30560: 'CalendarExtender' is ambiguous in the namespace 'AjaxControlToolkit'

$
0
0

I converted an old web site project to web form project and updated  AjaxControlToolKit to v15.1,  followinging instruction for AjaxControlToolkitupgrade. (https://ajaxcontroltoolkit.codeplex.com/wikipage?title=Upgrade%20your%20project%20to%20AjaxControlToolkit%20v15.1

Now I got BC30560 error for CalenderExtender.   I searched and tried many suggestions in the web and  removed and added reference to make sure there are no multiple  AjaxControlToolKit references. but still  could not resolve the issue

I appreciate if  someone here can shed some light on the problem

Please note if I create a new web form project, added a page with  AjaxControlToolkit CalenderExtender, it works fine.. But if I added a new page in the converted project, I saw the error.

Thanks

Viewing all 5678 articles
Browse latest View live


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