PDA

View Full Version : حرفه ای: اتصال اسکریپت گالری jQuery lightBox plugin با asp.net به sqlserver2005



nadia2174
شنبه 30 مهر 1390, 19:10 عصر
با سلام من می خوام برای نمایش تصاویر در سایتم که از دیتابیس sqlserver2005 میاد، از
اسکریپت گالری jQuery lightBox plugin با asp.net استفاده کنم. لطفا راهنماییم کنید چطور به دیتابیس وصلش کنم.
ممنون.

nadia2174
چهارشنبه 09 آذر 1390, 11:48 صبح
کسی این کار رو بلد نیست؟

jaykob
چهارشنبه 09 آذر 1390, 14:05 عصر
کسی این کار رو بلد نیست؟

سلام

برای ارسال که لازمه شما اصل عکس رو آپلود کنید و اسم عکس رو در دیتابیس ذخیره کنید و سپس باید یک thumb هم از عکس بسازید با حجم کم . برای نمایش هم شما هر گالری دارید در هر صورت با تگ های ul و li هست شما قسمت هایی که li خورده و مربوطه به نمایش عکس می شه یک literal می گذارید و سپس یک کوئری به دیتابیس می زنید و همه اسم را داخل آرایه ای می ریزید و با foreach تگ های را می نویسید . می تونید گزینه های دیگه ای مثل alt عکس را هم داینامیک کنید .

موفق باشید

behzad1367
شنبه 26 آذر 1390, 00:23 صبح
داداش منم میخام همین کار رو انجام بدم.خواهشا یه قطعه کد بزار

jaykob
شنبه 26 آذر 1390, 16:28 عصر
داداش منم میخام همین کار رو انجام بدم.خواهشا یه قطعه کد بزار

سلام دوست عزیز

شما به کد کدارم قسمت نیاز دارید ؟ چون چند بخش هست ( ساخت thumb - آپلود عکس - نمایش با lightbox , ...)

behzad1367
شنبه 26 آذر 1390, 19:18 عصر
همین که تصاویر رو از پایگاه داده بخونه.واسه thumb هم ممنون میشم توضیح بدی

jaykob
شنبه 26 آذر 1390, 19:29 عصر
همین که تصاویر رو از پایگاه داده بخونه.واسه thumb هم ممنون میشم توضیح بدی

سلام دوست عزیز

برای نمایش گالری خودتون می تونید یک literal داخل محیطی که می خواهید قرار بدید و از کد زیر استفاده کنید :



StringBuilder createlist = new StringBuilder();
public class MyQuery
{
public string Name { get; set; }

public string Info { get; set; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Portal.DataClassesDataContext db = new Portal.DataClassesDataContext();
var myQueries = db.tbl_galleries.OrderByDescending(x => x.id).Select(x => new MyQuery() { Name = x.url, Info = x.alt }).ToList();
myQueries.ForEach(x =>
{
createlist.AppendLine(string.Format("<li class=\"jfade_image\">"));
createlist.AppendLine(string.Format("<a href=\"/Portal/images/gallrey/{0}\" rel=\"example1\" title=\"{1}\" ><img src=\"/Portal/images/gallrey/thumb/{0}\"></a></li>", x.Name, x.Info));
LiteralGallery.Text = createlist.ToString();
});
}
}



البته html که داخل کد نوشته شده بر اساس اون کلاس css که برای اون مدل lightbox مورد نظر خودم هست شما هر مدل دیگه ای رو می تونید اجرا کنید .

برای ساختن thumb هم کد کاملش در قالب یک متد به شکل زیر هست :



private void ThumbCreate()
{
//////////////////////////////// spmall pic /////////////////////////////////////////

if (FileUpload1.HasFile)
{
// Find the fileUpload control
string filename = FileUpload1.FileName;

// Check if the directory we want the image uploaded to actually exists or not
if (!Directory.Exists(MapPath(@"\Portal\images\gallrey\thumb")))
{
// If it doesn't then we just create it before going any further
Directory.CreateDirectory(MapPath(@"\Portal\images\gallrey\thumb"));
}
// Specify the upload directory
string directory = Server.MapPath(@"\Portal\images\gallrey\thumb\");

// Create a bitmap of the content of the fileUpload control in memory
Bitmap originalBMP = new Bitmap(FileUpload1.FileContent);

// Calculate the new image dimensions
int origWidth = originalBMP.Width;
int origHeight = originalBMP.Height;
int sngRatio = origWidth / origHeight;
int newWidth = 210;
int newHeight = 100;

// Create a new bitmap which will hold the previous resized bitmap
Bitmap newBMP = new Bitmap(originalBMP, newWidth, newHeight);
// Create a graphic based on the new bitmap
Graphics oGraphics = Graphics.FromImage(newBMP);
// Set the properties for the new graphic file
oGraphics.SmoothingMode = SmoothingMode.AntiAlias; oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

// Draw the new graphic based on the resized bitmap
oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight);
// Save the new graphic file to the server
newBMP.Save(directory + filename);

// Once finished with the bitmap objects, we deallocate them.
originalBMP.Dispose();
newBMP.Dispose();
oGraphics.Dispose();

// Write a message to inform the user all is OK

}
else
{
lblResult.Text = "فایل thumb ساخته نشد";
}
///////////////////////////////////////////////////// small pic /////////////////////////////////////////////////
}



در صورتی که سوال دیگه ای بود من در خدمتم .

موفق باشید

behzad1367
یک شنبه 27 آذر 1390, 07:17 صبح
خیلی آقایی.داداش خب الان اینایی که گفتی رو چطوری و کجا باید ازشون استفاده کنم؟