15,896,726 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Umair Nafis (Top 59 by date)
Umair Nafis
14-Jun-19 7:26am
View
Sir I have updated the code plz check it.
Umair Nafis
14-Jun-19 7:26am
View
Deleted
Sir, I updated my code. Please review it.
Umair Nafis
14-Jun-19 5:33am
View
Thanks for the reply sir, I tried your suggestion , now i'm confused about how to display the result. I mean by your logic i got the final result from all table , now can you pleas tell me how to display that result in my view ?
Umair Nafis
20-Apr-19 3:16am
View
@christian Graus Thank you for the reply sir , here i updated my code kindly review it. im still getting the same error
Umair Nafis
28-Mar-19 2:15am
View
Thank you for support sir , here i posted the final query through which i got the actual result. U can see there .
Umair Nafis
27-Mar-19 18:46pm
View
means i can not join the query like i want >??
Umair Nafis
27-Mar-19 13:06pm
View
Thanks for the reply sir,
I used ToList() because i want all the rows from tbl_Model but a single row from tbl_ModelImg.
From above query which i wrote im getting all the rows from both tables, so i just want to write a query which return all the rows from tbl_Model and single row from tbl_ModelImg
Umair Nafis
9-Nov-17 4:48am
View
public static string RemoveHtmlTags(string input, int maximumLength)
{
// Remove the HTML tags:
string text = Regex.Replace(input, "<[^<>]*>", string.Empty);
// Limit the length:
if (text.Length > maximumLength)
{
text = text.Substring(0, maximumLength);
}
return text;
}
using(Database db = new Database())
{
var query = (
from c in db.tblBlogs
select new
{
c.BlogDescription
}).OrderBy(d => d.id).ToList().Take(10);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
query.ToList().ForEach(x =>
{
sb.Append(String.Fotrmat("{0}",RemoveHtmlTags(x.BlogDescription,200));
blogdiv.InnerHtml = sb.ToString();
}
}
Umair Nafis
7-Nov-17 9:56am
View
@Karthik , @Richard
Thanks Alottt sir, both of helped me alottt... I am very gratefull to you.
Now Everythings working awesome. Again Thanks Alottt :)
Umair Nafis
7-Nov-17 1:21am
View
Well I tried this RemoveHtmlTags(x.BlogDescription,200)
It removes the html text but max length is not working, it binds whole text?
Umair Nafis
7-Nov-17 0:34am
View
You mean I need to write something like this : RemoveHtmlTags(x.Blogdescription.ToString().Substring(0,200)) ????
or
x.BlogDescription(RemoveHtmlTags).ToString().SubString(0,200) ?
or
RemoveHtmlTags(x.BlogDescription, 200) ???
Umair Nafis
6-Nov-17 15:51pm
View
I just want to retrieve starting 200 words only form the data base , so i used x.BlogDescription.ToString().SubString(200), it display starting 200 characters from the data with html tags. i dnt want those html tags that's why i am asking the question about which method is used for retrieving limited tex frm database which contains html tags.
Umair Nafis
6-Nov-17 15:34pm
View
yes sir so how could i read the limited text ?? and that data which is present in database is richtext data which inserted from freetextbox control.
Umair Nafis
6-Nov-17 15:30pm
View
Deleted
var query = (
from c in db.tblBlogs
select new
{
c.id,
c.UserId,
c.CreatedDate,
c.Author,
c.BlogTitle,
c.BlogDescription
}).OrderBy(d => d.id).ToList().Take(10);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
query.ToList().ForEach(x =>
{
string bid = HttpUtility.UrlEncode(new StandardModule().Encrypt(x.id.ToString()));
var q = (from d in db.tblBlogMedias
join c in db.tblBlogs on d.BlogId equals x.id
select new
{
d.Id,
d.BlogPicturePath
}).OrderByDescending(d => d.Id).Max(d => d.BlogPicturePath);
sb.Append(string.Format("
{0}
by:{2}
"", x.BlogTitle, q, x.Author, x.BlogDescription));
}
});
blogdiv.InnerHtml = sb.ToString();
Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "activateReadmore()", true);
}
I want to bind that limited text in x.BlogDescription
Umair Nafis
6-Nov-17 15:24pm
View
ohh yeah ! actually you are absolutely right and i didnt recognise it before. lol
Thank You Sir.
Umair Nafis
6-Nov-17 11:31am
View
As I am a beginer in asp.net i really not able to get your point. :(
Umair Nafis
6-Nov-17 11:29am
View
and where this value1 will use. ?
Umair Nafis
6-Nov-17 11:23am
View
If i pass the visibility information in the query string which is present on page load than if a non registered user visit that page he can access that linkLikeButton, which creates nullexception like errors
Umair Nafis
6-Nov-17 11:21am
View
Sorry sir, but If possible can u please write the code for session , it will be very helpfull to me.
Umair Nafis
6-Nov-17 11:09am
View
this is my page load code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["uid"] != null)
{
getUser(Int64.Parse(new StandardModule().Decrypt(HttpUtility.UrlDecode(Request.QueryString["uid"])).ToString()));
if (Request.QueryString["bid"] != null)
{
blogg(Int64.Parse(new StandardModule().Decrypt(HttpUtility.UrlDecode(Request.QueryString["bid"])).ToString()));
bindblog();
FillCommentRepeater();
CommentsCount();
LikesCount();
pnlComment.Visible = true;
}
}
else if (Request.QueryString["bid"] != null)
{
blogg(Int64.Parse(new StandardModule().Decrypt(HttpUtility.UrlDecode(Request.QueryString["bid"])).ToString()));
bindblog();
CommentsCount();
}
else
{
bindblog();
}
}
}
Umair Nafis
6-Nov-17 11:08am
View
when i remove redirect whatever data present on the page disappear. even url values not changing
Umair Nafis
6-Nov-17 11:06am
View
Should I Re-Install Visual Studio?
Umair Nafis
6-Nov-17 11:01am
View
string uid = Request.QueryString["uid"].ToString();
string bid = Request.QueryString["bid"].ToString();
Response.Redirect(string.Format("blog.aspx?uid={0}&bid={1}", uid, bid), false);
Umair Nafis
6-Nov-17 11:00am
View
i tried but got the same result.
Umair Nafis
6-Nov-17 8:48am
View
FreeTextBoxDescription
Umair Nafis
5-Nov-17 11:10am
View
yes.
Umair Nafis
5-Nov-17 3:02am
View
It does not recognise HtmlStrippedText , putting dot after FreeTextBoxDescription. it shows Aggregate<>, All<> , Any<>, AsEnumerable<> and so on.....
Umair Nafis
4-Nov-17 13:49pm
View
sir i used freetextbox for inserting blog description into database, now when i bind that data on webpage it display all text. i want to show only limited text from blog description, I used x.blogDescription.ToString().SubString(200) , because of this method it shows html tag as well in the web page so is there any alternate solution of binding limited text of freetextbox/RichtextBox ? Thanks
Umair Nafis
3-Nov-17 15:06pm
View
How>?? what is result in this.? and where to use it ?
Umair Nafis
1-Nov-17 13:31pm
View
how to write this query in entity framework . ie the code written above:
select tblBlog.*,tblBlogMedia.BlogPicturePath from tblBlog left outer join tblBlogMedia on tblBlog.id = tblBlogMedia.BlogId
where tblBlogMedia.id=(select max(id) from tblBlogMedia where BlogId='1')
here BlogId='1' is just for example i want samething like BlogId = @blogid
Umair Nafis
26-Oct-17 12:15pm
View
No, actually the thing is that date stored in database in "plain text form" only but not with html tags. If the inserted data insert with html tags my problem will be solved. also i tried in backend
that freetextbox1.htmlStripedText.ToString(), which also not worked.
Umair Nafis
22-Oct-17 8:49am
View
When I debug the Code it show all the image path in a.blogPicturePath, but only bind the first image in gridview
GridBlog.DataSource = query;
GridBlog.DataBind();
Umair Nafis
17-Oct-17 10:57am
View
Problem is neigther about multiple files nor about valid or invalid files, The problem is when i upload 2 files 1 *.jpg file and other one is *.mp4 file then whatever i select first file in fileupload control it insert that file only which was selected first, and i want to insert both the files in different coloumn of the database table, i.e image path in image coloumn and video path in video coloumn.
I also tried "string ext = System.IO.Path.GetExtension(this.FileUpload.PostedFile.FileName)" under foreach loop then first it succesfully insert the image file than again for second file loop start with taking .mp4 value and executing the If statement of the .jpg body. and insert the video path in image coloumn.
I dont know why this if statement of .jpg is executing even after checking that the file is .mp4 This is the problem, I am facing.
Umair Nafis
16-Oct-17 16:05pm
View
Well I tried this validation also but the string ext = System.IO.Path.GetExtension(this.FileUpload.PostedFile.FileName); takes only one extension whis is selected first. ie If I select a image file of jpg format first then i select a video file of mp4 format than the ext takes only .jpg and execute only jpg part of the code, and in database the image inserted but video column having null value and vice versa.
Umair Nafis
16-Oct-17 16:04pm
View
Deleted
Well I tried this validation also but the string ext = System.IO.Path.GetExtension(this.FileUpload.PostedFile.FileName); takes only one extension whis is selected first. ie If I select a image file of jpg format first then i select a video file of mp4 format than the ext takes only .jpg and execute only jpg part of the code, and in database the image inserted but video column having null value and vice versa.
Umair Nafis
13-Oct-17 16:52pm
View
Images are stored in project folder and image path saved in sql server 2012 database
Umair Nafis
10-Oct-17 16:42pm
View
Sorry, I didnt get u. It will be very helpful if you provide some code or link.
Umair Nafis
10-Oct-17 7:45am
View
hello sir, thats fine i tried and it works but i want to add multiple images, from the above code I can only bind a signle image, suppose if a blog contains more than one image then how could i bind it?
Thanks alott
Umair Nafis
9-Oct-17 12:02pm
View
How to bind image of that particular blog in this tag : "" ie The image path is saved in the sqlserver and image in project folder, is it possible to bind those images in this tag? plz tell me i will be very grateful to u sir.
Umair Nafis
5-Oct-17 13:48pm
View
Thank You so much sir, you are awesome.
Sir but this method is not working for image binding as u can see here i directly displaying a single image in all blogs but if i use asp image control in this for dynamically bind images, imageId is not detected by the compiler.
Umair Nafis
5-Oct-17 13:09pm
View
Deleted
this code works absolutely fine but it looks so ordinary like 90's website in web view, so is it possible to apply some bootstrap classes to this or anything else.?
Thank you!
Umair Nafis
4-Oct-17 16:27pm
View
Actually i really dnt knw why i used ToList() here as i dnt what should be the best option to retrieve all the data from database. please correct me if i have better option than ToList(). I just want bind all the data..
Also sir i want to know if have any option to display only limited text in blog description with a read more link..hope u understand.
Umair Nafis
4-Oct-17 14:14pm
View
Thank You so much sir, it works I just used
query.ToList().ForEach(...),,...
Thanks Alott sir.
Umair Nafis
4-Oct-17 13:58pm
View
Thanx for the reply sir,
I tried your code but im getting error in ForEach()..are you missing a using directive or assembly reference.
Umair Nafis
14-Sep-17 10:14am
View
Deleted
I tried 1st link of video tutorial , but im stuck at this point
SqlParameter paramName = new SqlParameter()
{
ParameterName = @"Name",
Value = filename
};
here ParameterName is not recognised. what should i do now?
Umair Nafis
20-Aug-16 7:39am
View
Deleted
deleted
Umair Nafis
20-Aug-16 7:38am
View
.
Umair Nafis
20-Aug-16 7:36am
View
yess
Umair Nafis
20-Aug-16 7:35am
View
so what should i do now...im stuck in this problem since three days..
Umair Nafis
20-Aug-16 7:29am
View
protected void ddlcountry_SelectedIndexChanged(object sender, EventArgs e)
{
cmd = new SqlCommand("_pr_get_state", con);
cmd.CommandType=CommandType.StoredProcedure;
da=new SqlDataAdapter(cmd);
ds=new DataSet();
da.Fill(ds);
ddlstate.DataSource=ds;
ddlstate.DataTextField="statename";
ddlstate.DataValueField="stateid";
ddlstate.DataBind();
ddlstate.Items.Insert(0, new ListItem("---Select State---", "0"));
ddlcity.Items.Insert(0, new ListItem("---Select City---", "0"));
if (ddlcountry.SelectedValue == "0")
{
ddlcity.Items.Clear();
ddlcity.Items.Insert(0, new ListItem("---Select City---", "0"));
}
}
Umair Nafis
20-Aug-16 7:25am
View
tried this... bt it is also nt working :(
Umair Nafis
20-Aug-16 6:55am
View
--------------this is my code after using stored procedure---------------
protected void ddlcountry_SelectedIndexChanged(object sender, EventArgs e)
{
cmd = new SqlCommand("_pr_get_state", con);
cmd.CommandType=CommandType.StoredProcedure;
da=new SqlDataAdapter(cmd);
ds=new DataSet();
da.Fill(ds);
ddlstate.DataSource=ds;
ddlstate.DataTextField="statename";
ddlstate.DataValueField="stateid";
ddlstate.DataBind();
ddlstate.Items.Insert(0, new ListItem("---Select State---", "0"));
ddlcity.Items.Insert(0, new ListItem("---Select City---", "0"));
if (ddlstate.SelectedValue == "0")
{
ddlcity.Items.Clear();
ddlcity.Items.Insert(0, new ListItem("---Select City---", "0"));
}
}
---------and this query in sql server-------------
CREATE PROCEDURE _pr_get_state
@conid int
AS
BEGIN
select stateid,statename from get_state where conid=@conid
END
Umair Nafis
20-Aug-16 6:51am
View
i have deleted all the code and start from scratch....now i know the problem is in sql query which i write in as :-
da = new SqlDataAdapter("select stateid,statename from get_state where conid=" + conid, con);
do have any idea about this sytnax is correct or not ?
i even use stored procesdure in place of direct query bt the result is still same it is not taking any value from the database
Umair Nafis
20-Aug-16 5:34am
View
still not working
Umair Nafis
19-Aug-16 14:50pm
View
----------------Code Behind--------------------
protected void Page_Load(object sender, EventArgs e)
{
if (con.State == ConnectionState.Closed)
{
con.Open();
}
if (!Page.IsPostBack)
{
getcountry();
}
}
protected void getcountry()
{
try
{
da = new SqlDataAdapter("select * from get_country", con);
ds = new DataSet();
da.Fill(ds);
ddlcountry.DataSource = ds;
ddlcountry.DataTextField = "conname";
ddlcountry.DataValueField = "conid";
ddlcountry.DataBind();
ddlcountry.Items.Insert(0, new ListItem("--Select--", "0"));
ddlstate.Items.Insert(0, new ListItem("--Select--", "0"));
}
catch (Exception ex)
{
Response.Write("error occurd :" + ex.Message.ToString());
}
finally
{
con.Close();
}
}
protected void ddlcountry_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
int conid = Convert.ToInt32(ddlcountry.SelectedItem.Value.ToString());
da = new SqlDataAdapter("select stateid,statename from get_state where conid=" + conid, con);
ds = new DataSet();
da.Fill(ds);
ddlstate.DataSource = ds;
ddlstate.DataTextField = "statename";
ddlstate.DataValueField = "stateid";
ddlstate.DataBind();
ddlstate.Items.Insert(0, new ListItem("---Select State---", "0"));
if (ddlstate.SelectedValue == "0")
{
ddlcity.Items.Clear();
ddlcity.Items.Insert(0,new ListItem("---Select City---","0"));
}
}
catch(Exception ex)
{
Response.Write("error occurd :" + ex.Message.ToString());
}
finally
{
con.Close();
}
}
Umair Nafis
11-Aug-16 13:26pm
View
yes sir it's a webform. sir i want ask u one more thing that using only html controls instead of asp control is better idea or not..? i just want to use html control because in my form there is a dropdown list in which when i select country it autmatically detect the state of that country and display in state dropdown without refreshing the webpage.
so can i apply this ajax methoda to asp dropdown or not..?
Umair Nafis
11-Aug-16 13:22pm
View
thank you so much sir it works. actually i did'nt mention form id.
Umair Nafis
11-Aug-16 5:16am
View
the error is :- it ask to fill the fields of other form while im click on the button which present in another form
Umair Nafis
11-Aug-16 5:15am
View
i have write this code in asp.net ...its nt a MVC project.
i use simple html controls and form tag inside content place holder.
Show More