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

MultiHandleSlider: cant get even a simple working example to run

$
0
0

Hello,

Im using vs2012, all latest updates. Using the latest ajax control tookit 15.1.1.100

I am unable to get even a simple instance of this MultiHandleSlider to work and im tearing my hair out in frustration.

From this http://ajaxtoolkit.net/MultiHandleSlider/MultiHandleSlider.aspx I can see the control should work and its perfect for what I want.

I have created a simple new webforms basic solution, targeting .net 4.5.

Ive copy pasted basic samples from the web for this control. There are no errors when I run it. But the control only ever shows 1 single drag handle, even if I remove all MultiHandleSliderTarget it still shows 1 drag handle that drags ok.

If I try to access the list of MultiHandleSliderTarget in the code behind it shows the collection to be null.

   foreach (MultiHandleSliderTarget target in MultiHandleSliderExtender1.MultiHandleSliderTargets)
            target.ControlID = MultiHandleSliderExtender1.Parent.FindControl(target.ControlID).ClientID;

If I try to add them programmatically in code behind I get an error

Type 'AjaxControlToolkit.MultiHandleSliderTarget' in Assembly 'AjaxControlToolkit, Version=15.1.1.100, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' is not marked as serializable

So im pretty much at my wits end on this, does this control even work in any way ?

Im desperate I need some help please.

None of the target controls are in an containers its just a simple webform where im trying to get this multihandle control running.

<cc1:MultiHandleSliderExtender ID="MultiHandleSliderExtender1"
                                    runat="server" ShowHandleDragStyle="false"
                                    BehaviorID="MultiHandleSliderExtender1" TargetControlID="txtSlider"
                                    Length="500" ShowInnerRail="false"
                                    EnableMouseWheel="true" Increment="1"
                                    RaiseChangeOnlyOnMouseUp="true" EnableRailClick="true"
                                    OnClientDragEnd="" OnClientDrag=""
                                    ShowHandleHoverStyle="true"
                                    Maximum="222" Minimum="1" BoundControlID ="txtSlider">
                                    <cc1:MultiHandleSliderTargets>
                                        <cc1:MultiHandleSliderTarget ControlID="lblStartRange" runat="server" />
                                        <cc1:MultiHandleSliderTarget ControlID="lblEndRange" runat="server" />
                                      
                                    </cc1:MultiHandleSliderTargets>
                                </cc1:MultiHandleSliderExtender>


How to Have more than one Form to a single page to submit different-2 portions of Aspx page.

$
0
0

Hi,

I have designed a Login Page, and Using easy tabs on that Login page.

i.e. after opening the Login page I have two tabs on login page, 1st one is for Admin Login, and 2nd one is for User login.

on that page I have two div, 1 div contains the data of Admin Login: - User Name, Password, and Login Button.

on LoginButton_Click I retrieve the data from Admin table and validate to grant the access to Admin.

2nd div has the User Login Form: - User Name, Password, and Login Button

On the click of this button i retrieve data from User Table and validate to grant access to User.

For this I have 4 text boxes, and all four text boxes are set as "required" If I am using all these under single form then on click of Admin Login Button or User Login Button my form is not being submitted. because If admin wants to take login he is able to see only two text boxes another 2 text boxes are hidden. but they are required so form is not being submitted.

I tried using two form tag, but two form tag runat server is not allowed also.

So, please suggest the best possible method to do this.

Thank You.

Image viewer in ASP.Net

$
0
0

Hi all,

I need an image viewer in my ASP.Net website, What I do is, I load a gridview with list of images (thumbnails) and when user clicks on any image I'm supposed to show original image in an image viewer with download, rotate etc options. Could anyone please suggest any latest plugin or control for achieving this...?

-Rajesh

ASP.NET 4.5 C#: Ajax calendar only works after postback

$
0
0

Hello

In my webforms application I have a nested master page.

On this nested master page, inside an update panel,  I have an Ajax calendar extender that targets a textbox.

For some reason when the page is first loaded, the calendar extender does not display when I click the text box.

However, it works fine after I click a control that causes a postback.

My script manager is on the top-level master page.

The same text box and calendar extender works fine on a normal aspx page that links to the top-level master page.

In a nutshell, the problem seems to be that my calendar extender on my nested master page only displays after a postback.

Here is my mark-up:

<asp:UpdatePanel ID="uplTripPlanner" UpdateMode="Conditional" runat="server">
                        <ContentTemplate>
                            <div class="txtPadding">
                                <strong>Arrive</strong><br />
                                <asp:TextBox ID="txtTripArrive" runat="server" CssClass="txtDates"></asp:TextBox>
                                <cc1:CalendarExtender ID="txtTripArrive_CalendarExtender" runat="server"
                                    Enabled="True" TargetControlID="txtTripArrive" Format="dd/MM/yyyy"
                                    PopupButtonID="txtTripArrive">
                                </cc1:CalendarExtender>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="RequiredFieldValidator"
                                    ControlToValidate="txtTripArrive" ValidationGroup="TripDates" CssClass="WarningText10">* Required</asp:RequiredFieldValidator>
                                <asp:HiddenField ID="hfdTripArrive" runat="server" />
                                <asp:HiddenField ID="hfdTripDepart" runat="server" />
                                <br />
                                <strong>Depart</strong><br />
                                <asp:TextBox ID="txtTripDepart" runat="server" CssClass="txtDates"></asp:TextBox>
                                <cc1:CalendarExtender ID="txtTripDepart_CalendarExtender" runat="server"
                                    Enabled="True" TargetControlID="txtTripDepart" Format="dd/MM/yyyy" PopupButtonID="txtTripDepart">
                                </cc1:CalendarExtender>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"
                                    ControlToValidate="txtTripDepart" ValidationGroup="TripDates" CssClass="WarningText10">* Required</asp:RequiredFieldValidator>
                                <br />
                                <div style="text-align:right;">
                                    <asp:Button ID="btnTripDates" runat="server" Text="Go!"
                                        CssClass="btnTripDatesGo" ValidationGroup="TripDates"
                                            onclick="btnTripDates_Click" /></div>
                                    <asp:CompareValidator ID="CompareValidator1" Operator="GreaterThanEqual" Type="Date"
                                    ControlToValidate="txtTripDepart" ControlToCompare="txtTripArrive"
                                    ErrorMessage="Arrival must be BEFORE departure!"  runat="server" ValidationGroup="TripDates" CssClass="WarningText10" />
                            </div>
                        </ContentTemplate>
                    </asp:UpdatePanel>

Any suggestions are greatly appreciated.

Kind regards

Jubbs

Editor ajax control ToolKit

$
0
0

I save the Editor.content in sql server 2008 but it is saving the text in editor by html code

<p style="margin: 0px; text-align: right;">شسيشسيسشيشسي<br />  </p>

I want save شسيشسيسشيشسي only in sql server 

  Protected Sub Bsave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Bsave.Click
        Try

            Dim specf As String, specs As String, spect As String, speco As String, speci As String
            specf = Editspf.Content.ToString
            specs = Editsps.Content
            spect = Editspt.Content
            speco = Editspo.Content
            speci = Editspi.Content
            Dim o As New spec
            o.update(Request.QueryString("idc"), specf, specs, spect, speco, speci)
        Catch ex As Exception
            Response.Write(ex.Message)
        End Try
    End Sub

How can I do that please help me

How to Change the Value of Label and Display a Div

$
0
0

Hi Friends, I have designed a page to register employee.

Please go through the code of Page: -

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"><script src="javascripts/jquery-1.7.1.min.js" type="text/javascript"></script><script src="javascripts/jquery.hashchange.js" type="text/javascript"></script><script src="javascripts/jquery.easytabs.js" type="text/javascript"></script><link rel="Stylesheet" href="css/css/button.css" /><link rel="Stylesheet" href="css/menu.css" /><link rel="Stylesheet" href="css/base.css" /><link rel="Stylesheet" href="css/etab.css" /><%--<script src="js/jquery-1.11.1.min.js" type="text/javascript"></script>--%>   <!--Responsive--><meta name="viewport" content="width=device-width, initial-scale=1"/>   <!--Responsive--><script type="text/javascript">
        function PrintThis() {
            document.getElementById("RegisterEmp").style.display = "none";
            document.getElementById("btnPrint").style.display = "none";
            document.title = 'Employee Registration Number';
            window.print();
            document.getElementById("RegisterEmp").style.display = "block";
            document.getElementById("btnPrint").style.display = "block";
        }</script><script type="text/javascript">
        function register() {
            var name = document.getElementById("txtName").value;
            var gender = document.getElementById("ddlGender").value;
            var dob = document.getElementById("txtDOB").value;
            var mobile = document.getElementById("txtMobile").value;
            var url = "registerEmp.aspx?name=" + name + "&gender=" + gender + "&dob=" + dob + "&mobile=" + mobile;
            //alert(url);
            var search = new XMLHttpRequest();
            search.open("get", url, true);
            search.onreadystatechange = function () { f2(search); };
            search.send(null);
        }
        function f2(search) {
            if (search.readyState != 4)
                return;
            var id = search.responseText;$('#lblMessage').val('Registration Successfull.');$('#PrintReg').show(); $('#lblRegNo').val(id);
            //document.getElementById("lblMessage").innerHTML = "Registration Successfull.";
            //document.getElementById("PrintReg").style.display = "block";
            //document.getElementById("lblRegNo").innerHTML = id;
        }</script></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"><div class="tab-container" id="outer-container"><ul class='etabs'><li class='tab'><a href="#Add_Admin">Add Admin</a></li><li class='tab'><a href="#Add_Employee">Add Employee</a></li><li class='tab'><a href="#nested-tab-3">Contains more tabs</a></li></ul><div class="panel-container"><div id="Add_Admin"><h2>Heading 1</h2><p>This is the content of the first tab.</p></div><div id="Add_Employee"><div class="tab-container" id="inner-container-emp"><ul class='etabs'><li class='tab'><a href="#Register_Employee">Register Employee</a></li><li class='tab'><a href="#Create_Login_ID">Create Log-in ID</a></li></ul> <br /> <br /><div id="Register_Employee" style="text-align:left;">     <!--Contact Form-->  <br />    <div id="RegisterEmp"><form method="get" onsubmit="register()"><table><tr><td><input type="text" id="txtName" name="txtName" class="tb" required placeholder="Name *" title="Employee Name"/></td></tr><tr><td><br /></td></tr><tr><td><select id="ddlGender" class="ddl" required title="Employee Gender"><option value="Male" title="Male">Male</option><option title="Female" value="Female">Female</option></select></td></tr><tr><td><br /></td></tr><tr><td><input id="txtDOB" class="tb" required type="text" pattern="\d{1,2}-\d{1,2}-\d{4}" placeholder="Date of Birth *" title="DD-MM-YYYY"/></td></tr><tr><td><br /></td></tr><tr><td><input id="txtMobile" class="tb" required placeholder="Mobile *" type="tel" pattern="^\d{2}-\d{10}$" title="Write like 91-xxxxxxxxxx"/></td></tr><tr><td><br /></td></tr><tr><td><input type="submit" class="myButton" id="btnSave" title="Save" value="Save"/></td></tr><tr><td><br /></td></tr><tr><td><label id="lblMessage">hello!!</label></td></tr></table> </form> </div>  <div id="PrintReg" style="display:none;"><table><tr><td colspan="2">Please Keep Safe Your Registration Number!!</td></tr><tr><td>Registration No. is: </td><td><label id="lblRegNo" style="text-transform:lowercase;"></label></td></tr><tr><td colspan="2"><input type="button" class="myButton" value="Print" title="Print" id="btnPrint"  onclick="PrintThis()" /></td></tr></table>    </div><!-- content --></div>  <div id="Create_Login_ID"><p style="color:#ffffff;font-size:1.2em; font-weight:normal; font-family:Consolas;float:left; font-style: normal;"></p>  <!-- content --> <iframe src="LoginID.aspx" width="900px" frameborder="0" height="500px" scrolling="no"></iframe> <!-- content --> </div></div></div><div id="nested-tab-3"><h2>Heading 3</h2><p>More stuff from the last tab.</p><div class="tab-container" id="inner-container"><ul class='etabs'><li class='tab'><a href="#tab-a">Subtab A</a></li><li class='tab'><a href="#tab-b">Subtab B</a></li><li class='tab'><a href="#tab-c">Subtab C</a></li></ul><div class="panel-container"><div id="tab-a"><h3>Heading A</h3><p>This is a nested first tab</p></div><div id="tab-b"><h3>Heading B</h3><p>This is a nested second tab</p></div><div id="tab-c"><h3>Heading C</h3><p>This is a nested third tab</p></div></div><br /></div></div></div></div><script type="text/javascript">$('#outer-container, #inner-container, #inner-container-emp').easytabs();</script></asp:Content>

code of registerEmp.aspx is given below: -

 protected void Page_Load(object sender, EventArgs e)
    {
        string name= Request.QueryString["name"];
        string gender = Request.QueryString["gender"];
        string dob = Request.QueryString["dob"];
        string mobile = Request.QueryString["mobile"];
        string result = Utility.RegisterEmployee(name, gender, dob, mobile);
        Response.Write(result);        
    }

With the help of this code my data is being saved to database but I am unable to get the "Employee Registration Number", which is coming form "registerEmp.aspx" page. i.e. Response.Write(result);

As You see the code, I wanted to display my hidden div "PrintReg" after the successfull registration of employees. and Registration number should also be printed against HTML Label.

But Unable to do all these.

If there is any other best way possible to do all these things, then please suggest me.

But also give the suggestion to do all the things.

Thank You.

How do change text in Dropdownlist ?

$
0
0

Hello guys. I have use Dropdownlist . I try change text in Dropdownlist , but i can not. Seem it losts some data .

i.e : in Dropdownlist i have three data: AREA1,AREA2,AREA3, it load from ajax  .

<select id="cbo_area"></select>
   function cb_area() {$.ajax(
                {
                    type: "POST",
                    url: "../BUS/WebService.asmx/LIST_AREA", //// get list all area
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {$("#cbo_area").html('');$.each($.parseJSON(data.d), function (idx, obj) {$("#cbo_area").append(
                                '<option value="' + obj.AREA_ID + '">' + obj.AREA_NAME + '</option>');
                        });
                    },
                    error: function (data) {
                        alert("HTML Error Load Combo");
                    }
                });
            }

Ok, in my table , i click at row then click edit button, it will show data from row to Dropdownlist. it work but it only show one data , in this case "AREA2" (lost AREA1 and AREA3 in Dropdown) , i try click another row , i get that right , in this case "AREA3"  (lost AREA1 nad AREA2 in Dropdown), etc...

$('#bt_edit').click(function (e) {
                    var DTO = {
                        'area_id': area_id_temp
                    };$.ajax(
                    {
                        type: "POST",
                        url: "../BUS/WebService.asmx/AREA_NAME",  /// get name area follow id
                        data: JSON.stringify(DTO),
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (data) {$("#cbo_area").html('');
//cb_area(); // no work , it will loop data two times
/// it only will one data in Dropdownlist$.each($.parseJSON(data.d), function (idx, obj) {$("#cbo_area").append( '<option value="' + obj.AREA_ID + '">' + obj.AREA_NAME + '</option>'); });
//cb_area(); // no work, it will load wrong data }, error: function (data) { alert("HTML Error Load Edit"); } }); });

I want to click a row in table , Dropdownlist will change text from row and concurrentwith fieldsremaining data. i.e : when i click a row have "AREA1" , Dropdownlist text will change "AREA1" and more "AREA2" , "AREA3".Please give me some advice about this . Thank you.

GridView: Get Next Record With Next Command Update Panel and Button

$
0
0

I have a gridview inside an update panel that pages to the next record by clicking a button with a "next" command.

Do you have a solution that can automatically trigger the button with the next command?

I was thinking you could do it with a timer and a page load event for the button?


unable to get state code based on country code in autocompleteextender

$
0
0

 

Hi

I have gridview and AutocompleteExtender inside.

In footer if we select country name,State name list will be displayed.
If i select country,I get state based on country.

but i am not getting statecode in "txtftrStateCode" using " txtftrStateName_TextChanged(object sender, EventArgs e)"

I have to get statecode because it is passed as parameter to filter District

Please help me.I have given the code below.

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
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;
using System.Collections.Generic;
using AjaxControlToolkit;

public partial class _Default : System.Web.UI.Page
{
    private SqlConnection con = new SqlConnection("Data
Source=DELL-PC\\SQLEXPRESS;Initial Catalog=MySampleDB;Integrated
Security=True");
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindEmployeeDetails();
        }
    }
    protected void BindEmployeeDetails()
    {
        con.Open();
        string SqlQry = "Select *,CM.CountryName,SM.StateName "+ " from Employee_Details ED,CountryMaster CM,StateMaster SM where
ED.Statecode=SM.statecode and ED.CountryCode=CM.CountryCode ";

        SqlCommand cmd = new SqlCommand(SqlQry, con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        con.Close();
        if (ds.Tables[0].Rows.Count > 0)
        {
            gvDetails.DataSource = ds;
            gvDetails.DataBind();
        }
        else
        {
            ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
            gvDetails.DataSource = ds;
            gvDetails.DataBind();
            int columncount = gvDetails.Rows[0].Cells.Count;
            gvDetails.Rows[0].Cells.Clear();
            gvDetails.Rows[0].Cells.Add(new TableCell());
            gvDetails.Rows[0].Cells[0].ColumnSpan = columncount;
            gvDetails.Rows[0].Cells[0].Text = "No Records Found";
        }

    }

    protected void gvDetails_RowEditing(object sender, GridViewEditEventArgs e)
    {
        gvDetails.EditIndex = e.NewEditIndex;
        BindEmployeeDetails();
    }

    protected void gvDetails_RowUpdating(object sender,
GridViewUpdateEventArgs e)
    {
        int userid =
Convert.ToInt32(gvDetails.DataKeys[e.RowIndex].Value.ToString());
        string username =
gvDetails.DataKeys[e.RowIndex].Values["UserName"].ToString();
        TextBox txtStateName =
(TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtStateName");
        TextBox txtCountryName =
(TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtstate");
        con.Open();
        SqlCommand cmd = new SqlCommand("update Employee_Details set
State='" + txtStateName.Text + "',CountryName='" + txtCountryName.Text+ "' where UserId=" + userid, con);
        cmd.ExecuteNonQuery();
        con.Close();
        lblresult.ForeColor = Color.Green;
        lblresult.Text = username + " Details Updated successfully";
        gvDetails.EditIndex = -1;
        BindEmployeeDetails();
    }

    protected void gvDetails_RowCancelingEdit(object sender,
GridViewCancelEditEventArgs e)
    {
        gvDetails.EditIndex = -1;
        BindEmployeeDetails();
    }

    protected void gvDetails_RowDeleting(object sender,
GridViewDeleteEventArgs e)
    {
        int userid =
Convert.ToInt32(gvDetails.DataKeys[e.RowIndex].Values["UserId"].ToString());
        string username =
gvDetails.DataKeys[e.RowIndex].Values["UserName"].ToString();
        con.Open();
        SqlCommand cmd = new SqlCommand("delete from Employee_Details
where UserId=" + userid, con);
        int result = cmd.ExecuteNonQuery();
        con.Close();
        if (result == 1)
        {
            BindEmployeeDetails();
            lblresult.ForeColor = Color.Red;
            lblresult.Text = username + " details deleted successfully";
        }
    }

    protected void gvDetails_RowDataBound(object sender, GridViewRowEventArgs e)
    {

    }

    protected void gvDetails_RowCommand(object sender,
GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("AddNew"))
        {
            TextBox txtUsrname =
(TextBox)gvDetails.FooterRow.FindControl("txtftrUserName");
            TextBox txtftrStateName =
(TextBox)gvDetails.FooterRow.FindControl("txtftrStateName");
            TextBox txtftrCountryName =
(TextBox)gvDetails.FooterRow.FindControl("txtftrCountryName");
            con.Open();
            SqlCommand cmd =
                new SqlCommand("insert into
Employee_Details(UserName,StateCode,CountryCode) values('" +
txtUsrname.Text + "'," + txtftrStateName.Text + "," +
txtftrCountryName.Text + ")", con);
            int result = cmd.ExecuteNonQuery();
            con.Close();
            if (result == 1)
            {
                BindEmployeeDetails();
                lblresult.ForeColor = Color.Green;
                lblresult.Text = txtUsrname.Text + " Details inserted
successfully";
            }
            else
            {
                lblresult.ForeColor = Color.Red;
                lblresult.Text = txtUsrname.Text + " Details not inserted";
            }

        }
    }

   protected void txtftrStateName_TextChanged(object sender, EventArgs e)
        {         
           

            using (SqlCommand cmd = new SqlCommand())
            {

                SqlConnection conn = new SqlConnection(GetConnectionString());
                conn.Open();


                TextBox thisTextBox = (TextBox)sender;
                GridViewRow currentRow = (GridViewRow)thisTextBox.Parent.Parent;
                int rowindex = 0;
                rowindex = currentRow.RowIndex;
                TextBox txtftrStateName = (TextBox)currentRow.FindControl("txtftrStateName");
                string cmdText = "select StateName,StateCode from StateMaster where StateName = '" + txtftrStateName.Text + "'";
                cmd.CommandText = cmdText;
                cmd.Connection = conn;

                SqlDataAdapter sda = new SqlDataAdapter(cmd);

                DataTable dt = new DataTable();
                sda.Fill(dt);


                TextBox TextBox1 = sender as TextBox;
                GridViewRow gvr = TextBox1.NamingContainer as GridViewRow;
                TextBox txtftrStateCode = gvr.FindControl("txtftrStateCode") as TextBox;

                 if ((dt.Rows.Count > 0) && (dt != null))
                {
                    txtftrStateCode.Text =dt.Rows[0]["StateCode"].ToString();

                   
                    TextBox txtftrDistrictName = (TextBox)currentRow.FindControl("txtftrDistrictName") as TextBox;
                    AutoCompleteExtender autoCompleteExtender3 = (AutoCompleteExtender)currentRow.FindControl("AutoCompleteExtender3") as AutoCompleteExtender;

                        AutoCompleteExtender3.TargetControlID = txtftrDistrictName.ID;
                    autoCompleteExtender3.ServiceMethod = "SearchStateBranch";
                    autoCompleteExtender3.UseContextKey = true;
                }

            } 
        }
Thanks and regards
Ramachandran [System.Web.Script.Services.ScriptMethod()] [System.Web.Services.WebMethod] public static List<string> SearchCustomers(string prefixText, int count) { using (SqlCommand cmd = new SqlCommand()) { SqlConnection conn=new SqlConnection("Data Source=DELL-PC\\SQLEXPRESS;Initial Catalog=MySampleDB;Integrated Security=True"); conn.Open(); string cmdText = "select CountryName,CountryCode from CountryMaster where " +"CountryName like @SearchText + '%'"; cmd.Parameters.AddWithValue("@SearchText", prefixText); cmd.CommandText = cmdText; cmd.Connection = conn; List<string> Countries = new List<string>(); using (SqlDataReader sdr = cmd.ExecuteReader()) { while (sdr.Read()) { Countries.Add(sdr["CountryName"].ToString()); } } conn.Close(); return Countries; } } [System.Web.Script.Services.ScriptMethod()] [System.Web.Services.WebMethod] public static List<string> SearchState(string prefixText, int count, string contextKey) { using (SqlCommand cmd = new SqlCommand()) { SqlConnection conn = new SqlConnection("Data Source=DELL-PC\\SQLEXPRESS;Initial Catalog=MySampleDB;Integrated Security=True"); conn.Open(); string cmdText = "select StateName,StateCode from StateMaster where " +"StateName like @SearchText + '%'"; cmd.Parameters.AddWithValue("@SearchText", prefixText); if (contextKey != "0") { cmdText += " and CountryCode = @Country"; cmd.Parameters.AddWithValue("@Country", contextKey); } cmd.CommandText = cmdText; cmd.Connection = conn; List<string> States = new List<string>(); using (SqlDataReader sdr = cmd.ExecuteReader()) { while (sdr.Read()) { States.Add(sdr["StateName"].ToString()); } } conn.Close(); return States; } } protected void txtftrCountryName_TextChanged(object sender, EventArgs e) { using (SqlCommand cmd = new SqlCommand()) { SqlConnection conn = new SqlConnection("Data Source=DELL-PC\\SQLEXPRESS;Initial Catalog=MySampleDB;Integrated Security=True"); conn.Open(); TextBox thisTextBox = (TextBox)sender; GridViewRow currentRow = (GridViewRow)thisTextBox.Parent.Parent; int rowindex = 0; rowindex = currentRow.RowIndex; TextBox txt = (TextBox)currentRow.FindControl("txtftrCountryName"); string cmdText = "select CountryName,CountryCode from CountryMaster where " +"CountryName = '" + txt.Text + "'"; cmd.CommandText = cmdText; cmd.Connection = conn; SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt); TextBox txt1 = (TextBox)currentRow.FindControl("txtftrHCountryCode"); txt1.Text = dt.Rows[0]["CountryCode"].ToString(); TextBox txtftrHCountryCode = (TextBox)currentRow.FindControl("txtftrHCountryCode"); TextBox txtftrStateName = (TextBox)currentRow.FindControl("txtftrStateName") as TextBox; AutoCompleteExtender autoCompleteExtender2 =(AutoCompleteExtender)currentRow.FindControl("AutoCompleteExtender2") as AutoCompleteExtender; autoCompleteExtender2.ContextKey = txtftrHCountryCode.Text; autoCompleteExtender2.TargetControlID = txtftrStateName.ID; autoCompleteExtender2.ServiceMethod = "SearchState"; autoCompleteExtender2.UseContextKey = true; } } protected void gvDetails_RowDataBound1(object sender, GridViewRowEventArgs e) { if(e.Row.RowType==DataControlRowType.Footer) { TextBox txtftrHCountryCode = e.Row.FindControl("txtftrHCountryCode") as TextBox; TextBox txtftrStateName = e.Row.FindControl("txtftrStateName") as TextBox; AutoCompleteExtender autoCompleteExtender2 = e.Row.FindControl("AutoCompleteExtender2") as AutoCompleteExtender; autoCompleteExtender2.ContextKey = txtftrHCountryCode.Text; autoCompleteExtender2.TargetControlID = txtftrStateName.ID; autoCompleteExtender2.ServiceMethod = "SearchState"; autoCompleteExtender2.UseContextKey = true; //getting username from particular row string username = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "UserName")); //identifying the control in gridview ImageButton lnkbtnresult = (ImageButton)e.Row.FindControl("imgbtnDelete"); //raising javascript confirmationbox whenver user clicks on link button if (lnkbtnresult != null) { lnkbtnresult.Attributes.Add("onclick","javascript:return ConfirmationBox('" + username + "')"); } } } }
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %><%@ Register Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"><title>Untitled Page</title><style type="text/css">
        .Gridview {
            font-family: Verdana;
            font-size: 10pt;
            font-weight: normal;
            color: black;
        }</style><script type="text/javascript">
        function ConfirmationBox(username) {

            var result = confirm('Are you sure you want to delete ' +
username + ' Details?');
            if (result) {

                return true;
            }
            else {
                return false;
            }
        }
    </script></head><body><form id="form1" runat="server"><asp:ScriptManager ID="ScriptManager1"
runat="server"></asp:ScriptManager><div><asp:GridView ID="gvDetails"
DataKeyNames="UserId,UserName" runat="server"
                AutoGenerateColumns="false" CssClass="Gridview"
HeaderStyle-BackColor="#61A6F8"
                ShowFooter="true" HeaderStyle-Font-Bold="true"
HeaderStyle-ForeColor="White"
                OnRowCancelingEdit="gvDetails_RowCancelingEdit"
                OnRowDeleting="gvDetails_RowDeleting"
OnRowEditing="gvDetails_RowEditing"
                OnRowUpdating="gvDetails_RowUpdating"
                OnRowCommand="gvDetails_RowCommand"
OnRowDataBound="gvDetails_RowDataBound1"><Columns><asp:TemplateField><EditItemTemplate><asp:ImageButton ID="imgbtnUpdate"
CommandName="Update" runat="server" ImageUrl="~/Images/update.jpg"
ToolTip="Update" Height="20px" Width="20px" /><asp:ImageButton ID="imgbtnCancel"
runat="server" CommandName="Cancel" ImageUrl="~/Images/Cancel.jpg"
ToolTip="Cancel" Height="20px" Width="20px" /></EditItemTemplate><ItemTemplate><asp:ImageButton ID="imgbtnEdit"
CommandName="Edit" runat="server" ImageUrl="~/Images/Edit.jpg"
ToolTip="Edit" Height="20px" Width="20px" /><asp:ImageButton ID="imgbtnDelete"
CommandName="Delete" Text="Edit" runat="server"
ImageUrl="~/Images/delete.jpg" ToolTip="Delete" Height="20px"
Width="20px" /></ItemTemplate><FooterTemplate><asp:ImageButton ID="imgbtnAdd"
runat="server" ImageUrl="~/Images/AddNewitem.jpg" CommandName="AddNew"
Width="30px" Height="30px" ToolTip="Add new User"
ValidationGroup="validaiton" /></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="State"><EditItemTemplate><asp:TextBox ID="txtStateName"
runat="server" Text='<%#Eval("StateCode") %>' /></EditItemTemplate><ItemTemplate><asp:Label ID="lblStateName"
runat="server" Text='<%#Eval("StateName") %>' /></ItemTemplate><FooterTemplate><asp:TextBox ID="txtftrStateName" runat="server" /><asp:RequiredFieldValidator ID="rfvState"
runat="server"
                                ControlToValidate="txtftrStateName"
Text="*" ValidationGroup="validaiton" /><cc1:AutoCompleteExtender
ID="AutoCompleteExtender2" TargetControlID="txtftrStateName"
                                UseContextKey="true"
MinimumPrefixLength="1" EnableCaching="true"
                                CompletionInterval="500"
ServiceMethod="SearchState" runat="server"></cc1:AutoCompleteExtender><asp:TextBox ID="txtftrStateCode" EnableViewState="true" AutoPostBack="true" runat="server"    /></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="Country"><EditItemTemplate><asp:TextBox ID="txtCountryName"
runat="server" Text='<%#Eval("CountryCode") %>' /></EditItemTemplate><ItemTemplate><asp:Label ID="lblCountryName"
runat="server" Text='<%#Eval("CountryName") %>' /></ItemTemplate><FooterTemplate><asp:TextBox ID="txtftrCountryName"
runat="server" AutoPostBack="True"
OnTextChanged="txtftrCountryName_TextChanged" /><asp:RequiredFieldValidator
ID="rfvtxtftrCountryName" runat="server"
ControlToValidate="txtftrCountryName" Text="*"
ValidationGroup="validaiton" /><cc1:AutoCompleteExtender ID="AutoCompleteExtender1"
                                runat="server"
TargetControlID="txtftrCountryName"
                                MinimumPrefixLength="1"
EnableCaching="true" CompletionSetCount="1"
                                CompletionInterval="500"
ServiceMethod="SearchCustomers"></cc1:AutoCompleteExtender><asp:TextBox ID="txtftrHCountryCode"
AutoPostBack="true" runat="server"></asp:TextBox></FooterTemplate></asp:TemplateField></Columns><HeaderStyle BackColor="#61A6F8" Font-Bold="True"
ForeColor="White"></HeaderStyle></asp:GridView><asp:SqlDataSource ID="SqlDataSource1"
runat="server"></asp:SqlDataSource></div><div><asp:Label ID="lblresult" runat="server"></asp:Label></div>



Updatepanel,progressbar,downloading a documnet in code behind

$
0
0

Hi,

Button is inside the update panel,and there is a progress bar .Progress bar working fine but documnet is not getting downloaded.

If  i add triggers i will not see the progressbar image.

Please suggest me .Is i can achiev this using ajaxcontrols

Error in ScriptManager in Real Host

Open UserControl As PopUp on ImageButton_Click Or Whatever Else Will Work

$
0
0

I have an ASPX page.  On this ASPX page, there is an image button.  

I also have a user control (ASCX).

Upon clicking the image button, I would like the ASCX to pop-up in a modal dialog box.

I have the AjaxControlToolkit in my solution.

Is it possible to open an ASCX control from a button on an ASPX page?  

I've tried several approaches with no success and am looking for fresh ideas.

Thanks, cj

System.OutOfMemoryException using linq C#

$
0
0

Hi All,

Please resolve this issue .  

It contains around 30000 records. When grouping using Linq to list. It throws error of System.OutOfMemoryException

var resultdt = dt.GroupBy(test => new { test.CompanyName, test.MainTelNumber, test.Address, test.Address2, test.City, test.State, test.ZipCode, test.EventCity, test.JobCategory, test.WebsiteURL, test.EventState })
.Select(grp => grp.First())
.ToList();



Help on cascading dropdownlist using ajax

$
0
0

Hi Pls I av been working on cascading a dropdownlist with ajax but the issue is I have completely finished with my coding, passing parameters, but the isue is that when ever I run my Webservices, and I invoked my bind state and City, it tels me thatvalue cannot be null.

here is my code:

public class WebService : System.Web.Services.WebService {
     SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbConnectStrings"].ConnectionString);
   // Bind Archive
    [WebMethod]
    public CascadingDropDownNameValue[] BindArchive(string knownCategoryValues, string category) 
    {
       DataSet ds = new DataSet();
        conn.Open();//select * from [ST-Dep]
        SqlCommand cmd = new SqlCommand("select distinct empd.arc, empc.EmpCategoryId,empc.EmpCategoryName from Doc empd INNER JOIN EmpCategory empc On empd.arc = empc.EmpCategoryId", conn);
        SqlDataAdapter adp = new SqlDataAdapter(cmd);
        cmd.ExecuteNonQuery();
        adp.Fill(ds);
        conn.Close();

        List<CascadingDropDownNameValue> ArchiveDetails = new List<CascadingDropDownNameValue> ();
        foreach (DataRow Dr in ds.Tables[0].Rows)
        {
            string ArcID = Dr["arc"].ToString();
            string ArcName = Dr["EmpCategoryName"].ToString();

            ArchiveDetails.Add(new CascadingDropDownNameValue(ArcName, ArcID));

    }
    return ArchiveDetails.ToArray();
}
    //Folder
    [WebMethod]
    public CascadingDropDownNameValue[] BindFolder(string knownCategoryValues, string category)
    {
    DataSet ds = new DataSet();
    char ArcID;
    StringDictionary ArchiveDetails = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
    ArcID = Convert.ToChar(ArchiveDetails["arc"]);
    conn.Open();//SELECT  * From [ST-Dep] where DepId=@DepId
    SqlCommand cmd = new SqlCommand("select distinct empd.folder,dep.DepId,dep.DepName From Doc empd INNER JOIN [ST-Dep] dep ON empd.folder = dep.DepId where empd.archive= @DepId ", conn);
    cmd.Parameters.AddWithValue("@DepId", ArcID);
    cmd.ExecuteNonQuery();
        SqlDataAdapter adp = new SqlDataAdapter(cmd);
        adp.Fill(ds);
        conn.Close();
         List<CascadingDropDownNameValue> FolderDetails = new List<CascadingDropDownNameValue> ();
        foreach (DataRow Dr in ds.Tables[0].Rows)
        {
            string FolderID = Dr["folder"].ToString();
            string FolderName = Dr["DepName"].ToString();
            FolderDetails.Add(new CascadingDropDownNameValue(FolderName, FolderID));
        }
        return FolderDetails.ToArray();
        }
    //SubFolder bind
    [WebMethod]
    public CascadingDropDownNameValue[] BinSubfolder(string knownCategoryValues, string category)
    {
        DataSet ds = new DataSet();
        char FolderID;
        StringDictionary folderdetails = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
        FolderID = Convert.ToChar(folderdetails["DepName"]);
        conn.Open();//Select * From Doc where folder = @Folder
        SqlCommand cmd = new SqlCommand("select distinct empd.subfolder, trad.TradeId, trad.TradeName From Doc empd INNER JOIN [Trade] trad ON empd.subfolder = trad.TradeId where (empd.folder = @Folder)", conn);
        cmd.Parameters.AddWithValue("@Folder", FolderID);
        cmd.ExecuteNonQuery();
        SqlDataAdapter adp = new SqlDataAdapter(cmd);
        adp.Fill(ds);
        conn.Close();
        List<CascadingDropDownNameValue> SubFoldetails = new List<CascadingDropDownNameValue>();
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            string SubFolID = dr["subfolder"].ToString();
            string subFolName = dr["TradeName"].ToString(); 
SubFoldetails.Add(new CascadingDropDownNameValue(subFolName, SubFolID)); } return SubFoldetails.ToArray(); } }

and Here is my Category in my CASCADINGDROPDOWN
<asp:CascadingDropDown ID="ccarchive" runat="server" Category="arc" TargetControlID="ddarchive" LoadingText="Loading Archives.." PromptText="Select Archive" ServiceMethod="BindArchive" ServicePath="~/WebService.asmx"   /><asp:CascadingDropDown ID="ccFolder" runat="server" Category="DepId" TargetControlID="ddFolder" ParentControlID="ddarchive" LoadingText="Loading Folders.." PromptText="Select Folder" ServiceMethod="BindFolder" ServicePath="~/WebService.asmx" /><asp:CascadingDropDown ID="ccSubfolder" runat="server" Category ="TradeId"  TargetControlID ="ddSubfolder" ParentControlID ="ddFolder" LoadingText="Loading SubFolders" PromptText ="Select SubFolder" ServiceMethod="BindSubfolder" ServicePath="~/WebService.asmx"/>  

Ps can som1 elp me out with what might av been causing it to retun a null value

Thanks

Enter event issue in textbox because of update panel inside updatepanel

$
0
0

Hi Friends,

I have some issue in my code.

This is search functionality code. When I enter some text in textbox and click search, the results are displaying correctly. But when I enter text in textbox and click enter without pressing search button , all results are displaying irrespective of text which I entered. Please let me know any issues with the code.

This is the sample code. Based on the below sample code when I enter text in textbox and enter, it is always firing "Letter_Click" event. not hidden search button click. I dont know why this issue is happenning. Is it because of update panel or I am not sure.Please can you help me out from this issue.

 

<!--Update Progress is now out of the update panel, otherwise we were getting some JScript errors--> <div class="updateProgress"> <asp:UpdateProgress ID="updateProgress" AssociatedUpdatePanelID="UpdatePanel1" DynamicLayout="false" DisplayAfter="0" runat="server">    <ProgressTemplate>         <asp:Image ID="Image3" ImageUrl="~/Images/spinner_small.gif" runat="server" AlternateText="" GenerateEmptyAlternateText="true" />     </ProgressTemplate> </asp:UpdateProgress> </div>    <asp:UpdatePanel ID="UpdatePanel1" runat="server" Visible="true" >            <ContentTemplate>        

                         <asp:Panel ID="paraPanel" Visible="false" runat="server" Style="cursor: move;background-color:white;border:solid 1px Gray;color:blue">               </asp:Panel>         <div id="pcontent">       <div class="messagepanel">        <mes:Message ID="userMessage" runat="server"/>     </div>                 <asp:UpdatePanel ID="upLetters" runat="server"  UpdateMode = "Conditional" Visible="true" RenderMode="Inline">            <ContentTemplate>      <ul class="searchbar">          <li class="firstitem"><asp:ImageButton id="btn_" runat="server" CommandArgument="_" OnClick="Letter_Click" ImageUrl="~/images/popup/hash.gif" AlternateText="Search #" Width="19" Height="18" TabIndex="-1" CausesValidation="false" /></li>          <li><asp:ImageButton id="btnA" runat="server" CommandArgument="A" OnClick="Letter_Click" ImageUrl="~/images/popup/A.gif" AlternateText="Search A" Width="19" Height="18" TabIndex="-1" CausesValidation="false" /></li>            </ContentTemplate>    </asp:UpdatePanel>

</div> <!--pcontent-->

    <div class="searchtxtbox" runat=server id="searchtxtbox">         <asp:label id="lblCriteriaCaption" AssociatedControlID="txtSearchCriteria" runat="server">Missing Title</asp:label>         <asp:TextBox ID="txtSearchCriteria" runat="server" TabIndex="1"></asp:TextBox>    </div>       <div class="searchbtn">         <asp:ImageButton id="btnSearch" OnClick="btnSearch_Click"  runat="server" ImageUrl="~/images/search_btn.gif" AlternateText="Search" CausesValidation="false"/>         <asp:ImageButton id="btnHiddenSearch" OnClick="btnHiddenSearch_Click"  runat="server" ImageUrl="~/images/search_btn.gif" AlternateText="Search hidden" CausesValidation="false" style="display:none"/>         </div>

    </ContentTemplate>    </asp:UpdatePanel>

Thanks Bhavani


ajaxcontroltoolkit maskededitextender time is not working backspace in google chrome

$
0
0

why ajaxcontroltoolkit maskededitextender time is not working backspace in google chrome

plz help me..

How to prevent flash light of Ajax Real Time Chart - MS Chart

The Controls collection cannot be modified because the control contains code blocks (i.e. ).

$
0
0

Hi Guys,

I am getting below error when adding Ajax calendar extender to textbox control, I have few javascripts in master page but can't <%= to <%# as it doesn't work. Below is the error

<script src='<%= ResolveUrl("~/assets/vendor/jquery/jquery.js") %>'></script><script src='<%= ResolveUrl("~/assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js") %>'></script><script src='<%= ResolveUrl("~/assets/vendor/bootstrap/js/bootstrap.js") %>'></script><script src='<%= ResolveUrl("~/assets/vendor/nanoscroller/nanoscroller.js") %>'></script><script src='<%= ResolveUrl("~/assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js") %>'></script>

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Thanks,

Shabbir

Calling a webservice in html using webservice.htc?

$
0
0

Hi,

I am testing a webservice and consuming it in html. The webservice is working fine, but when I use it in html, I get an error that the "service object doesn't support the method 'useService'". Please help me in solving this. I have the webservice.htc file from Microsoft in the html file folder. Thanks.

<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><title>UseSwap</title><script lang="JavaScript">
        function InitializeService(){
            service.useService( "http://localhost:51559/WebService.asmx?WSDL" , "Feedback" );
        }
        var a1, a2, a3, a4, a5, a6;
        function Insert(){
            a1 = document.myForm.q1.value;
            a2 = document.myForm.q2.value;
            a3 = document.myForm.q3.value;
            service.Feedback.callService("insert", a1, a2, a3);
        }
        function ShowResult(){
            alert(event.result.value);
        }</script></head><body onload="InitializeService()" id="service" style="behavior:url(webservice.htc)" ><form name="myForm">
       a1 : <input type="text" name="q1"/>
       a2 : <input type="text" name="q2"/>
       a3 : <input type="text" name="q3"/><button onclick="Insert()">Submit</button></form></body></html>

Exception in ExecuteScalar()?

$
0
0

Hi,

I am testing a webservice. Something went wrong in the query. Help me out.

[WebMethod]
    public int login(string name, string pass)
    {
        OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\c#\feedback.mdb");
        con.Open();
        OleDbCommand command = con.CreateCommand();
        command.CommandText = "SELECT pass FROM stud where user=" +name;
        command.ExecuteScalar();
        string p = command.ExecuteScalar().ToString();
        con.Close();
        if (pass == p)
        {
            return 1;
        }
        else
            return 0;
    }

Viewing all 5678 articles
Browse latest View live


Latest Images

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