It's ModalPopupExtender Control
---------------------------------------------------------------------------
In the Model PopUp Extender control has TargetControlD in this property you have to pass that Button Control ID on which you want to open the popup.
and popupControlID Property you pass the which control ID which you want to Make the Popup like here Panal control.
and On CancelContolID you have to pass the cancel button ID by which Popup will close.
Note-: If you want when Popup is opened your back ground opacity reduced 70%.
You have to pass the modalBackground css in the ModelPopupExtender property BackgroundCssClass.
----------------------------------------------------------------------
Here is CSS-:
.modalBackground {
background-color:Gray;
filter:alpha(opacity=70);
opacity:0.7;
}
-----------------------------------------------------------------------------
ajaxToolkit:ModalPopupExtender ID="mpeAddForum" runat="server"
TargetControlID="btnAddModerator"
PopupControlID="pnlModerator"
BackgroundCssClass="modalBackground"
DropShadow="false"
CancelControlID="btnCancelPopup" EnableViewState="false" />
----------------------------------------------------------------------------------
asp:Panel ID="pnlModerator" runat="server" Width="400px" Height="250px" >
table >
tr>
td> Enter User Name
asp:TextBox ID="txtname" runat="server">
/td>
/tr>
tr>
td>
asp:Button ID="btnPopupSaveModerator" runat="server" Text="Save" onclick="btnPopupSaveModerator_Click" />
asp:Button ID="btnCancelPopup" runat="server" Text="Cancel"/>
/td>
/tr>
/table>
/asp:Panel>
here some invalid tags---please ignore it ....
Thursday, July 3, 2008
AutoCompleteExtender Ajax
Its the AutoCompleteExtender Ajax Control :-
-------------------
When you Create write the words in the TextBox at a time web service i Method GetData() call & fetch the values from the database & return the String Array of the data that show in the TextBox.
----------------------
asp:TextBox ID="txtname" runat="server" >
ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" Enabled="true" runat="server" MinimumPrefixLength="1" TargetControlID="txtname" CompletionSetCount="20" CompletionInterval="0000" EnableCaching="true" ServiceMethod="GetData" ServicePath="~/WebService.asmx">
Note-: Here is some invalid tags. Please Ignore it.......
-------------------------------------------------------------------------
It's a web service-:
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.IO;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
///
/// Summary description for WebService
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService
{
[WebMethod]
public string[] GetData(string prefixText)
{
List listString = new List();
using (SqlConnection con = new SqlConnection("Initial Catalog=Employee;Server=local;User ID=sa;Password=sa;"))
{
SqlCommand cm = new SqlCommand("SELECT top 5 name FROM WeFire_User Where Name like '" + prefixText + "%'", con);
con.Open();
SqlDataReader dr = cm.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
listString.Add(dr["name"].ToString());
}
}
}
string[] str = listString.ToArray();
return str;
}
}
-------------------
When you Create write the words in the TextBox at a time web service i Method GetData() call & fetch the values from the database & return the String Array of the data that show in the TextBox.
----------------------
asp:TextBox ID="txtname" runat="server" >
ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" Enabled="true" runat="server" MinimumPrefixLength="1" TargetControlID="txtname" CompletionSetCount="20" CompletionInterval="0000" EnableCaching="true" ServiceMethod="GetData" ServicePath="~/WebService.asmx">
Note-: Here is some invalid tags. Please Ignore it.......
-------------------------------------------------------------------------
It's a web service-:
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.IO;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
///
/// Summary description for WebService
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService
{
[WebMethod]
public string[] GetData(string prefixText)
{
List
using (SqlConnection con = new SqlConnection("Initial Catalog=Employee;Server=local;User ID=sa;Password=sa;"))
{
SqlCommand cm = new SqlCommand("SELECT top 5 name FROM WeFire_User Where Name like '" + prefixText + "%'", con);
con.Open();
SqlDataReader dr = cm.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
listString.Add(dr["name"].ToString());
}
}
}
string[] str = listString.ToArray();
return str;
}
}
File Upload
when You call the AddImage Method first it will check the value of FileUpload contrlol if it has the postedfile its call the mehtod (UploadImage(FileUpload1.PostedFile.FileName, FileUpload1))
...............
this code is the suitable for saving the images in the Image Folder & it's return the image name.
private string AddImage()
{
string strFilename = "";
if ((FileUpload1.PostedFile == null || FileUpload1.PostedFile.ContentLength == 0))
{
strFilename = "";
}
else
{
strFilename = UploadImage(FileUpload1.PostedFile.FileName, FileUpload1);
}
return strFilename;
}
private string UploadImage(string filePath, FileUpload fileUpload)
{
string strFilename = "";
try
{
strFilename = System.IO.Path.GetFileName(filePath);
Random rnd = new Random();
int prefix = rnd.Next();
strFilename = prefix.ToString() + strFilename;
string path = Server.MapPath("~");
string fullPath = path + "/" + "images";
DirectoryInfo dirinfo = new DirectoryInfo(fullPath);
if (dirinfo.Exists)
{
string strFilePath = fullPath + "\\" + strFilename;
fileUpload.PostedFile.SaveAs(strFilePath);
}
else
{
dirinfo.Create();
string strFilePath = fullPath + "\\" + strFilename;
fileUpload.PostedFile.SaveAs(strFilePath);
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
return strFilename;
}
...............
this code is the suitable for saving the images in the Image Folder & it's return the image name.
private string AddImage()
{
string strFilename = "";
if ((FileUpload1.PostedFile == null || FileUpload1.PostedFile.ContentLength == 0))
{
strFilename = "";
}
else
{
strFilename = UploadImage(FileUpload1.PostedFile.FileName, FileUpload1);
}
return strFilename;
}
private string UploadImage(string filePath, FileUpload fileUpload)
{
string strFilename = "";
try
{
strFilename = System.IO.Path.GetFileName(filePath);
Random rnd = new Random();
int prefix = rnd.Next();
strFilename = prefix.ToString() + strFilename;
string path = Server.MapPath("~");
string fullPath = path + "/" + "images";
DirectoryInfo dirinfo = new DirectoryInfo(fullPath);
if (dirinfo.Exists)
{
string strFilePath = fullPath + "\\" + strFilename;
fileUpload.PostedFile.SaveAs(strFilePath);
}
else
{
dirinfo.Create();
string strFilePath = fullPath + "\\" + strFilename;
fileUpload.PostedFile.SaveAs(strFilePath);
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
return strFilename;
}
Subscribe to:
Posts (Atom)