Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Colombo
YEYE 3 in 1 Instant Coffee Mix 50 Sachet
Romeshka
Updated:
Today at 12:16 AM
Colombo
Red Hat Certified System Administrator (RHCSA) - RHEL 10
Sanjeewani95
Updated:
Friday at 7:43 PM
NURSING , CAREGIVER , HOTEL & BEAUTY COURSES
IVA Para Medical Campus
Updated:
Thursday at 9:24 AM
Handmade Character Soft Toys Peppa Pig Family
anil1961
Updated:
Jul 1, 2026
Ad icon
Video Content Creator
pramukag
Updated:
Jun 28, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
Computers & Internet
Software Development
ASP.NET weddo ennawada?? Help akak ona
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Snowl" data-source="post: 11189989" data-attributes="member: 374230"><p>මේක වැඩ කරනවා මම developed කරේ ,ඒ වගේම test කරලා බැලුවා කිහිප සැරයක්ම</p><p>හොදට වැඩ කරනවා. <img src="/styles/default/xenforo/smilies/default/happy.gif" class="smilie" loading="lazy" alt=":)" title="Happy :)" data-shortname=":)" /></p><p>නමුත් පිළිවෙලට යන්න මොකද Validation System එක ඒ තරම් හොද මදි.</p><p>ඔයාට ප්රශ්ණයක් තියෙනවා නම් කියන්න මම බලන්නම් මොකද කරන්න පුලුවන් කියලා.</p><p></p><p>මුලින්ම Database එකක් හදාගන්න මේක තියෙන්නේ SQL වලින්</p><p>Access කරන්න ඕන නම් SQL -> OleDb කරන්න </p><p>එකේ connection string එක මෙතනට දාන්න</p><p>connectionStr = ""</p><p>එච්චරයි තියෙන්නේ ඒ වගේම මේක වැඩ කරන්නේ Online තියෙනවා නම් විතරයි</p><p>මොකද ActiveX player එක Firefox,Opera,Safari වල වැඩ </p><p>කරන්නේ නැති නිසා වෙනම flashplayer එකක් use කරන්න වුනා මට.</p><p>මේ file 2ක් විතරයි ඕන වෙන්නේ. ඒ වගේම මේකේ database එකේ</p><p>columns හදනවා Automatically ඒකේ තියෙන්නේ id එක සහා path එක</p><p>විතරයි. </p><p></p><p>මුලින්ම යන්න මේ විදියට </p><p>Create database එක ඔබන්න එතනින් database එක හදනවා Application එකෙන්ම</p><p>ඊට පස්සේ Browse කියන button එක මගින් අදාළ file එක select කරලා</p><p>ඊට එහා පැත්තේ තියෙන Save button එකෙන් upload කරගන්න මේකෙන් වැඩ</p><p>දෙකක් වෙනවා එකක් තමයි file එක upload වෙන එක අනෙක database එකට</p><p>අදාළ file එකේ server path එක යන එක.</p><p>ඊට පස්සේ සෑහෙන තරම් records database එකේ තියෙන කොට Retrieve button</p><p>එක ඔබලා අදාළ files වල path ටික ගන්න පුලුවන්. දැන් මේ file එකක්</p><p>play කරගන්න ඕන නම් කෙළවරේම තියෙන listbox එකේ ඕන file එක</p><p>select කරලා Select කියන button එක ඔබන්න ඒකෙන් mp3 player එක</p><p>draw කරනවා HTML එක මත දැන් play කියන button එක ඔබලා music එක</p><p>අහන්න. </p><p></p><p></p><p></p><p></p><p><strong>sound.aspx.cs</strong></p><p>[CODE]</p><p></p><p>using System;</p><p>using System.Collections.Generic;</p><p>using System.Web;</p><p>using System.Web.UI;</p><p>using System.Web.UI.WebControls;</p><p>using System.Data.SqlClient;</p><p></p><p>public partial class sound : System.Web.UI.Page</p><p>{</p><p></p><p> String connectionStr = "";</p><p></p><p> protected void Page_Load(object sender, EventArgs e)</p><p> { </p><p> </p><p> }</p><p></p><p> //############ EVENTS ###################################################################</p><p> protected void Retrieve(object sender, EventArgs e)</p><p> {</p><p> loadAllSoundFiles();</p><p> }</p><p></p><p> protected void createDatabase(object sender, EventArgs e)</p><p> {</p><p> proCreateTheDatabase();</p><p> }</p><p></p><p> protected void saveFile(object sender, EventArgs e)</p><p> {</p><p> proUploadFile();</p><p> }</p><p></p><p> protected void audioSelect_Click(object sender, EventArgs e)</p><p> {</p><p> string getSoundFile = allAudioFiles.SelectedValue;</p><p> makeMp3Player(getSoundFile);</p><p> }</p><p> //############################################################################################</p><p></p><p></p><p></p><p> //################## PROCEDURES ##############################################################</p><p> //<---------- Create The Database ------></p><p> public void proCreateTheDatabase()</p><p> {</p><p> SqlConnection con = new SqlConnection(connectionStr);</p><p> String sqlCommand = "CREATE TABLE sound(soundID INT NOT NULL,soundPath VARCHAR(200) NOT NULL,PRIMARY KEY(soundID))";</p><p> SqlCommand cmd = new SqlCommand(sqlCommand, con);</p><p></p><p> try</p><p> {</p><p> con.Open();</p><p> cmd.ExecuteNonQuery();</p><p> con.Close();</p><p> Response.Write("<script type='text/javascript'>alert('Database is created by Snowl.!');</script>");</p><p> }</p><p> catch (Exception error)</p><p> {</p><p> Response.Write("<script type='text/javascript'>alert('There is an error, perhaps you already made it mister.!');</script>");</p><p> }</p><p> }</p><p></p><p> //<---------- Upload The File to the Server ------></p><p> public void proUploadFile()</p><p> {</p><p> String filePath = soundUpload.PostedFile.FileName;</p><p> if (!filePath.Equals("") && !filePath.Equals(null))</p><p> {</p><p> String serverPath = Server.MapPath("~/" + filePath.ToString());</p><p> proUpdateDatabase(serverPath);</p><p> soundUpload.PostedFile.SaveAs(serverPath);</p><p> }</p><p> else</p><p> {</p><p> Response.Write("<script type='text/javascript'>alert('You must first select a file to upload.! :P');</script>");</p><p> }</p><p> }</p><p></p><p> //<---------- Update The Database ------></p><p> public void proUpdateDatabase(String filePath)</p><p> {</p><p> SqlConnection con = new SqlConnection(connectionStr);</p><p> String sqlCommand = "INSERT INTO sound(soundID,soundPath) VALUES(@soundID,@soundPath)";</p><p> SqlCommand cmd = new SqlCommand(sqlCommand, con);</p><p> int previousID = proGetPreviousId();</p><p> int newId = previousID + 1;</p><p> cmd.Parameters.AddWithValue("@soundID",newId);</p><p> cmd.Parameters.AddWithValue("@soundPath", filePath);</p><p></p><p> try</p><p> {</p><p> con.Open();</p><p> cmd.ExecuteNonQuery();</p><p> con.Close();</p><p> Response.Write("<script type='text/javascript'>alert('Record is created by Snowl.!');</script>");</p><p> }</p><p> catch (Exception error)</p><p> {</p><p> Response.Write("<script type='text/javascript'>alert('There is an error in updating the database.');</script>");</p><p> }</p><p> }</p><p></p><p> //<------------ Get previous id's number ---------></p><p> public int proGetPreviousId()</p><p> {</p><p> int takeId = 0;</p><p> SqlConnection con = new SqlConnection(connectionStr);</p><p> String sqlCommand = "SELECT soundID FROM sound";</p><p> SqlCommand cmd = new SqlCommand(sqlCommand,con);</p><p></p><p> try</p><p> {</p><p> con.Open();</p><p> SqlDataReader read = cmd.ExecuteReader();</p><p> while(read.Read())</p><p> {</p><p> takeId = int.Parse(read["soundID"].ToString());</p><p> }</p><p> con.Close();</p><p> int lastId = takeId;</p><p> return lastId;</p><p> }</p><p> catch (Exception error)</p><p> {</p><p> return 0; //This means there is NO value so start from the beginning</p><p> }</p><p> }</p><p></p><p> // <---------- Retrieve the Sound file and put it with the mp3 player ----------></p><p> public void makeMp3Player(string soundFileServerPath)</p><p> {</p><p> String fileToBePlayed = "";</p><p></p><p> if (soundFileServerPath.Contains("http://"))</p><p> {</p><p> int start = soundFileServerPath.LastIndexOf("//");</p><p> fileToBePlayed = soundFileServerPath.Substring(start+1);</p><p> }</p><p> else</p><p> {</p><p> int start = soundFileServerPath.LastIndexOf("\\");</p><p> fileToBePlayed = soundFileServerPath.Substring(start+1);</p><p> }</p><p></p><p> </p><p></p><p> //Example of Local URL c:\file\mpfile.mp3</p><p> String mp3PlayerCommands = "<object type='application/x-shockwave-flash' data='http://flash-mp3-player.net/medias/player_mp3.swf' width='200' height='20'>" +</p><p> "<param name='movie' value='http://flash-mp3-player.net/medias/player_mp3.swf' />" +</p><p> "<param name='bgcolor' value='#ffffff' />" +</p><p> "<param name='FlashVars' value='mp3=" + fileToBePlayed + "' />" +</p><p> "</object>";</p><p> mp3PlayerDrawHere.InnerHtml = mp3PlayerCommands;</p><p> }</p><p></p><p> public void loadAllSoundFiles()</p><p> {</p><p> allAudioFiles.Items.Clear();//Clear All Previous items from the item List</p><p> SqlConnection con = new SqlConnection(connectionStr);</p><p> String sqlCommand = "SELECT soundPath FROM sound";</p><p> SqlCommand cmd = new SqlCommand(sqlCommand, con);</p><p></p><p> try</p><p> {</p><p> con.Open();</p><p> SqlDataReader read = cmd.ExecuteReader();</p><p> while (read.Read())</p><p> {</p><p> allAudioFiles.Items.Add(read["soundPath"].ToString());</p><p> }</p><p> con.Close();</p><p> }</p><p> catch (Exception error)</p><p> {</p><p> Response.Write("<script type='text/javascript'>alert('There is an error in searching in the database.');</script>");</p><p> }</p><p> }</p><p> //#############################################################################################</p><p></p><p>}</p><p>[/CODE]</p><p></p><p></p><p><strong>sound.aspx</strong></p><p>[CODE]</p><p></p><p></p><p><%@ Page Language="C#" AutoEventWireup="true" CodeFile="sound.aspx.cs" Inherits="sound" %></p><p></p><p><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></p><p></p><p><html xmlns="http://www.w3.org/1999/xhtml"></p><p><head runat="server"></p><p> <title></title></p><p> <script language="javascript" type="text/javascript"></p><p></p><p> </script></p><p></head></p><p><body></p><p> <form id="form1" runat="server"></p><p> <div></p><p> </p><p> <asp:Button ID="btnRetrieve" runat="server" onclick="Retrieve" </p><p> Text="Retrieve" /></p><p> <asp:FileUpload ID="soundUpload" runat="server" /></p><p> </p><p> <asp:Button ID="btncreateDatabase" runat="server" onclick="createDatabase" </p><p> Text="Create The Database" /></p><p> </p><p> <asp:Button ID="btnsaveFile" runat="server" onclick="saveFile" </p><p> Text="Save File" /></p><p> </p><p> <asp:DropDownList ID="allAudioFiles" runat="server"></p><p> </asp:DropDownList></p><p> <asp:Button ID="audioSelect" runat="server" onclick="audioSelect_Click" </p><p> Text="Select File" /></p><p> </div></p><p> </form></p><p> <div id="mp3PlayerDrawHere" runat="server"></p><p> </div></p><p></body></p><p></html></p><p></p><p></p><p></p><p>[/CODE]</p><p></p><p><strong>//Snowl//</strong></p></blockquote><p></p>
[QUOTE="Snowl, post: 11189989, member: 374230"] මේක වැඩ කරනවා මම developed කරේ ,ඒ වගේම test කරලා බැලුවා කිහිප සැරයක්ම හොදට වැඩ කරනවා. :) නමුත් පිළිවෙලට යන්න මොකද Validation System එක ඒ තරම් හොද මදි. ඔයාට ප්රශ්ණයක් තියෙනවා නම් කියන්න මම බලන්නම් මොකද කරන්න පුලුවන් කියලා. මුලින්ම Database එකක් හදාගන්න මේක තියෙන්නේ SQL වලින් Access කරන්න ඕන නම් SQL -> OleDb කරන්න එකේ connection string එක මෙතනට දාන්න connectionStr = "" එච්චරයි තියෙන්නේ ඒ වගේම මේක වැඩ කරන්නේ Online තියෙනවා නම් විතරයි මොකද ActiveX player එක Firefox,Opera,Safari වල වැඩ කරන්නේ නැති නිසා වෙනම flashplayer එකක් use කරන්න වුනා මට. මේ file 2ක් විතරයි ඕන වෙන්නේ. ඒ වගේම මේකේ database එකේ columns හදනවා Automatically ඒකේ තියෙන්නේ id එක සහා path එක විතරයි. මුලින්ම යන්න මේ විදියට Create database එක ඔබන්න එතනින් database එක හදනවා Application එකෙන්ම ඊට පස්සේ Browse කියන button එක මගින් අදාළ file එක select කරලා ඊට එහා පැත්තේ තියෙන Save button එකෙන් upload කරගන්න මේකෙන් වැඩ දෙකක් වෙනවා එකක් තමයි file එක upload වෙන එක අනෙක database එකට අදාළ file එකේ server path එක යන එක. ඊට පස්සේ සෑහෙන තරම් records database එකේ තියෙන කොට Retrieve button එක ඔබලා අදාළ files වල path ටික ගන්න පුලුවන්. දැන් මේ file එකක් play කරගන්න ඕන නම් කෙළවරේම තියෙන listbox එකේ ඕන file එක select කරලා Select කියන button එක ඔබන්න ඒකෙන් mp3 player එක draw කරනවා HTML එක මත දැන් play කියන button එක ඔබලා music එක අහන්න. [B]sound.aspx.cs[/B] [CODE] using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; public partial class sound : System.Web.UI.Page { String connectionStr = ""; protected void Page_Load(object sender, EventArgs e) { } //############ EVENTS ################################################################### protected void Retrieve(object sender, EventArgs e) { loadAllSoundFiles(); } protected void createDatabase(object sender, EventArgs e) { proCreateTheDatabase(); } protected void saveFile(object sender, EventArgs e) { proUploadFile(); } protected void audioSelect_Click(object sender, EventArgs e) { string getSoundFile = allAudioFiles.SelectedValue; makeMp3Player(getSoundFile); } //############################################################################################ //################## PROCEDURES ############################################################## //<---------- Create The Database ------> public void proCreateTheDatabase() { SqlConnection con = new SqlConnection(connectionStr); String sqlCommand = "CREATE TABLE sound(soundID INT NOT NULL,soundPath VARCHAR(200) NOT NULL,PRIMARY KEY(soundID))"; SqlCommand cmd = new SqlCommand(sqlCommand, con); try { con.Open(); cmd.ExecuteNonQuery(); con.Close(); Response.Write("<script type='text/javascript'>alert('Database is created by Snowl.!');</script>"); } catch (Exception error) { Response.Write("<script type='text/javascript'>alert('There is an error, perhaps you already made it mister.!');</script>"); } } //<---------- Upload The File to the Server ------> public void proUploadFile() { String filePath = soundUpload.PostedFile.FileName; if (!filePath.Equals("") && !filePath.Equals(null)) { String serverPath = Server.MapPath("~/" + filePath.ToString()); proUpdateDatabase(serverPath); soundUpload.PostedFile.SaveAs(serverPath); } else { Response.Write("<script type='text/javascript'>alert('You must first select a file to upload.! :P');</script>"); } } //<---------- Update The Database ------> public void proUpdateDatabase(String filePath) { SqlConnection con = new SqlConnection(connectionStr); String sqlCommand = "INSERT INTO sound(soundID,soundPath) VALUES(@soundID,@soundPath)"; SqlCommand cmd = new SqlCommand(sqlCommand, con); int previousID = proGetPreviousId(); int newId = previousID + 1; cmd.Parameters.AddWithValue("@soundID",newId); cmd.Parameters.AddWithValue("@soundPath", filePath); try { con.Open(); cmd.ExecuteNonQuery(); con.Close(); Response.Write("<script type='text/javascript'>alert('Record is created by Snowl.!');</script>"); } catch (Exception error) { Response.Write("<script type='text/javascript'>alert('There is an error in updating the database.');</script>"); } } //<------------ Get previous id's number ---------> public int proGetPreviousId() { int takeId = 0; SqlConnection con = new SqlConnection(connectionStr); String sqlCommand = "SELECT soundID FROM sound"; SqlCommand cmd = new SqlCommand(sqlCommand,con); try { con.Open(); SqlDataReader read = cmd.ExecuteReader(); while(read.Read()) { takeId = int.Parse(read["soundID"].ToString()); } con.Close(); int lastId = takeId; return lastId; } catch (Exception error) { return 0; //This means there is NO value so start from the beginning } } // <---------- Retrieve the Sound file and put it with the mp3 player ----------> public void makeMp3Player(string soundFileServerPath) { String fileToBePlayed = ""; if (soundFileServerPath.Contains("http://")) { int start = soundFileServerPath.LastIndexOf("//"); fileToBePlayed = soundFileServerPath.Substring(start+1); } else { int start = soundFileServerPath.LastIndexOf("\\"); fileToBePlayed = soundFileServerPath.Substring(start+1); } //Example of Local URL c:\file\mpfile.mp3 String mp3PlayerCommands = "<object type='application/x-shockwave-flash' data='http://flash-mp3-player.net/medias/player_mp3.swf' width='200' height='20'>" + "<param name='movie' value='http://flash-mp3-player.net/medias/player_mp3.swf' />" + "<param name='bgcolor' value='#ffffff' />" + "<param name='FlashVars' value='mp3=" + fileToBePlayed + "' />" + "</object>"; mp3PlayerDrawHere.InnerHtml = mp3PlayerCommands; } public void loadAllSoundFiles() { allAudioFiles.Items.Clear();//Clear All Previous items from the item List SqlConnection con = new SqlConnection(connectionStr); String sqlCommand = "SELECT soundPath FROM sound"; SqlCommand cmd = new SqlCommand(sqlCommand, con); try { con.Open(); SqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { allAudioFiles.Items.Add(read["soundPath"].ToString()); } con.Close(); } catch (Exception error) { Response.Write("<script type='text/javascript'>alert('There is an error in searching in the database.');</script>"); } } //############################################################################################# } [/CODE] [B]sound.aspx[/B] [CODE] <%@ Page Language="C#" AutoEventWireup="true" CodeFile="sound.aspx.cs" Inherits="sound" %> <!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 runat="server"> <title></title> <script language="javascript" type="text/javascript"> </script> </head> <body> <form id="form1" runat="server"> <div> <asp:Button ID="btnRetrieve" runat="server" onclick="Retrieve" Text="Retrieve" /> <asp:FileUpload ID="soundUpload" runat="server" /> <asp:Button ID="btncreateDatabase" runat="server" onclick="createDatabase" Text="Create The Database" /> <asp:Button ID="btnsaveFile" runat="server" onclick="saveFile" Text="Save File" /> <asp:DropDownList ID="allAudioFiles" runat="server"> </asp:DropDownList> <asp:Button ID="audioSelect" runat="server" onclick="audioSelect_Click" Text="Select File" /> </div> </form> <div id="mp3PlayerDrawHere" runat="server"> </div> </body> </html> [/CODE] [B]//Snowl//[/B] [/QUOTE]
Insert quotes…
Verification
Hata thunen beduwama keeyada? (60 bedeema thuna)
Post reply
Top
Bottom